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