Delete any character in a given String. @param inString the original String @param charsToDelete a set of characters to delete. E.g. "az\n" will delete 'a's, 'z's and new lines. @return the resulting String
(String inString, String charsToDelete)
| 583 | * @return the resulting String |
| 584 | */ |
| 585 | public static String deleteAny(String inString, String charsToDelete) { |
| 586 | if (!hasLength(inString) || !hasLength(charsToDelete)) { |
| 587 | return inString; |
| 588 | } |
| 589 | StringBuilder sb = new StringBuilder(); |
| 590 | for (int i = 0; i < inString.length(); i++) { |
| 591 | char c = inString.charAt(i); |
| 592 | if (charsToDelete.indexOf(c) == -1) { |
| 593 | sb.append(c); |
| 594 | } |
| 595 | } |
| 596 | return sb.toString(); |
| 597 | } |
| 598 | |
| 599 | |
| 600 | //--------------------------------------------------------------------- |
no test coverage detected