Last active
August 29, 2015 14:05
-
-
Save xzzz9097/e07432563dcb2ab94185 to your computer and use it in GitHub Desktop.
Remove part of string - Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Quick method to remove a specified part of a string | |
* @param remove - the string part to remove | |
* @param from - the original string | |
* @return - the cut string | |
*/ | |
public static String removeStringFromString(String remove, String from) { | |
char lastCharacter = remove.charAt(remove.length() - 1); | |
int cutStart = from.lastIndexOf(lastCharacter) + 1; | |
return from.substring(cutStart); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment