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

Method trimFrom

output/java_guava/1.4.19/CharMatcher.java:916–931  ·  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

914
915
916 public String trimFrom(CharSequence sequence) {
917 int len = sequence.length();
918 int first;
919 int last;
920 for (first = 0; first < len; first++) {
921 if (!matches(sequence.charAt(first))) {
922 break;
923 }
924 }
925 for (last = len - 1; last > first; last--) {
926 if (!matches(sequence.charAt(last))) {
927 break;
928 }
929 }
930 return sequence.subSequence(first, last + 1).toString();
931 }
932
933 /**
934 * 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