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

Method trimTrailingFrom

output/java_guava/1.4.13/CharMatcher.java:964–972  ·  view source on GitHub ↗

Returns a substring of the input character sequence that omits all characters this matcher matches from the end of the string. For example: CharMatcher.anyOf("ab").trimTrailingFrom("abacatbab") ... returns "abacat".

(CharSequence sequence)

Source from the content-addressed store, hash-verified

962
963
964 public String trimTrailingFrom(CharSequence sequence) {
965 int len = sequence.length();
966 for (int last = len - 1; last >= 0; last--) {
967 if (!matches(sequence.charAt(last))) {
968 return sequence.subSequence(0, last + 1).toString();
969 }
970 }
971 return "";
972 }
973
974 /**
975 * Returns a string copy of the input character sequence, with each group of consecutive

Callers

nothing calls this directly

Calls 3

matchesMethod · 0.95
toStringMethod · 0.65
lengthMethod · 0.45

Tested by

no test coverage detected