/** * Returns {@code true} if a character sequence contains no matching * characters. * * <p>The default implementation iterates over the sequence, invoking {@link * #matches} for each character, until this returns {@code false} or the end is * reached. * * @param sequence the character sequence to examine, possibly empty * @return {@code true} if this matcher matches every character in the * sequence, including when the sequence is empty */ public boolean matchesNoneOf(CharSequence sequence) { return indexIn(sequence) == -1; }
/** * Returns {@code true} if a character sequence contains no matching * characters. * * <p>The default implementation iterates over the sequence, invoking {@link * #matches} for each character, until this returns {@code false} or the end is * reached. * * @param sequence the character sequence to examine, possibly empty * @return {@code true} if this matcher matches every character in the * sequence, including when the sequence is empty */ public boolean matchesNoneOf(CharSequence sequence) { return indexIn(sequence) == -1; }
/** * Returns {@code true} if a character sequence contains no matching * characters. * * <p>The default implementation iterates over the sequence, invoking {@link * #matches} for each character, until this returns {@code false} or the end is * reached. * * @param sequence the character sequence to examine, possibly empty * @return {@code true} if this matcher matches every character in the * sequence, including when the sequence is empty */ public boolean matchesNoneOf(CharSequence sequence) { return indexIn(sequence) == -1; }
int pos = indexIn(string); if (pos == -1) { return string;
int pos = indexIn(string); if (pos == -1) { return string;
int pos = indexIn(string); if (pos == -1) { return string;
/** * Collapses groups of matching characters exactly as {@link #collapseFrom} * does, except that groups of matching characters at the start or end of the * sequence are removed without replacement. */ public String trimAndCollapseFrom(CharSequence sequence, char replacement) { int first = negate().indexIn(sequence); if (first == -1) { return ""; // everything matches. nothing's left. } StringBuilder builder = new StringBuilder(sequence.length()); boolean inMatchingGroup = false; for (int i = first; i < sequence.length(); i++) { char c = sequence.charAt(i); if (apply(c)) { inMatchingGroup = true; } else { if (inMatchingGroup) { builder.append(replacement); inMatchingGroup = false; } builder.append(c); } } return builder.toString(); }
/** * Collapses groups of matching characters exactly as {@link #collapseFrom} * does, except that groups of matching characters at the start or end of the * sequence are removed without replacement. */ public String trimAndCollapseFrom(CharSequence sequence, char replacement) { int first = negate().indexIn(sequence); if (first == -1) { return ""; // everything matches. nothing's left. } StringBuilder builder = new StringBuilder(sequence.length()); boolean inMatchingGroup = false; for (int i = first; i < sequence.length(); i++) { char c = sequence.charAt(i); if (apply(c)) { inMatchingGroup = true; } else { if (inMatchingGroup) { builder.append(replacement); inMatchingGroup = false; } builder.append(c); } } return builder.toString(); }
/** * Collapses groups of matching characters exactly as {@link #collapseFrom} * does, except that groups of matching characters at the start or end of the * sequence are removed without replacement. */ public String trimAndCollapseFrom(CharSequence sequence, char replacement) { int first = negate().indexIn(sequence); if (first == -1) { return ""; // everything matches. nothing's left. } StringBuilder builder = new StringBuilder(sequence.length()); boolean inMatchingGroup = false; for (int i = first; i < sequence.length(); i++) { char c = sequence.charAt(i); if (apply(c)) { inMatchingGroup = true; } else { if (inMatchingGroup) { builder.append(replacement); inMatchingGroup = false; } builder.append(c); } } return builder.toString(); }
int pos = indexIn(string); if (pos == -1) { return string;
int first = indexIn(sequence); if (first == -1) { return sequence.toString();
int pos = indexIn(string); if (pos == -1) { return string;
int pos = indexIn(string); if (pos == -1) { return string;
int first = indexIn(sequence); if (first == -1) { return sequence.toString();
int first = indexIn(sequence); if (first == -1) { return sequence.toString();