MCPcopy Create free account
hub / github.com/jwtk/jjwt / deleteAny

Method deleteAny

api/src/main/java/io/jsonwebtoken/lang/Strings.java:585–597  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 //---------------------------------------------------------------------

Calls 4

hasLengthMethod · 0.95
indexOfMethod · 0.80
toStringMethod · 0.65
lengthMethod · 0.45

Tested by

no test coverage detected