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