MCPcopy Create free account
hub / github.com/antlr/codebuff / trimFrom

Method trimFrom

output/java_guava/1.4.13/CharMatcher.java:917–932  ·  view source on GitHub ↗

Returns a substring of the input character sequence that omits all characters this matcher matches from the beginning and from the end of the string. For example: CharMatcher.anyOf("ab").trimFrom("abacatbab") ... returns "cat". Note that: {@code CharM

(CharSequence sequence)

Source from the content-addressed store, hash-verified

915
916
917 public String trimFrom(CharSequence sequence) {
918 int len = sequence.length();
919 int first;
920 int last;
921 for (first = 0; first < len; first++) {
922 if (!matches(sequence.charAt(first))) {
923 break;
924 }
925 }
926 for (last = len - 1; last > first; last--) {
927 if (!matches(sequence.charAt(last))) {
928 break;
929 }
930 }
931 return sequence.subSequence(first, last + 1).toString();
932 }
933
934 /**
935 * Returns a substring of the input character sequence that omits all characters this matcher

Callers

nothing calls this directly

Calls 3

matchesMethod · 0.95
toStringMethod · 0.65
lengthMethod · 0.45

Tested by

no test coverage detected