Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,5 @@
|
|||
String stripCharacters(String string, String characters) {
|
||||
for (char character : characters.toCharArray())
|
||||
string = string.replace(String.valueOf(character), "");
|
||||
return string;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
String stripCharacters(String string, String characters) {
|
||||
StringBuilder stripped = new StringBuilder(string);
|
||||
/* traversing the string backwards is necessary to avoid collision */
|
||||
for (int index = string.length() - 1; index >= 0; index--) {
|
||||
if (characters.contains(String.valueOf(string.charAt(index))))
|
||||
stripped.deleteCharAt(index);
|
||||
}
|
||||
return stripped.toString();
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
static String stripCharacters(String string, String characters) {
|
||||
/* be sure to 'quote' the 'characters' to avoid pattern collision */
|
||||
characters = Pattern.quote(characters);
|
||||
string = string.replaceAll("[%s]".formatted(characters), "");
|
||||
return string;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue