< prev index next >
src/java.base/share/classes/java/util/regex/Matcher.java
Print this page
*** 256,266 ****
/**
* Returns the match state of this matcher as a {@link MatchResult}.
* The result is unaffected by subsequent operations performed upon this
* matcher.
*
! * @return a <code>MatchResult</code> with the state of this matcher
* @since 1.5
*/
public MatchResult toMatchResult() {
return toMatchResult(text.toString());
}
--- 256,266 ----
/**
* Returns the match state of this matcher as a {@link MatchResult}.
* The result is unaffected by subsequent operations performed upon this
* matcher.
*
! * @return a {@code MatchResult} with the state of this matcher
* @since 1.5
*/
public MatchResult toMatchResult() {
return toMatchResult(text.toString());
}
*** 345,355 ****
}
}
/**
! * Changes the <tt>Pattern</tt> that this <tt>Matcher</tt> uses to
* find matches with.
*
* <p> This method causes this matcher to lose information
* about the groups of the last match that occurred. The
* matcher's position in the input is maintained and its
--- 345,355 ----
}
}
/**
! * Changes the {@code Pattern} that this {@code Matcher} uses to
* find matches with.
*
* <p> This method causes this matcher to lose information
* about the groups of the last match that occurred. The
* matcher's position in the input is maintained and its
*** 357,367 ****
*
* @param newPattern
* The new pattern used by this matcher
* @return This matcher
* @throws IllegalArgumentException
! * If newPattern is <tt>null</tt>
* @since 1.5
*/
public Matcher usePattern(Pattern newPattern) {
if (newPattern == null)
throw new IllegalArgumentException("Pattern cannot be null");
--- 357,367 ----
*
* @param newPattern
* The new pattern used by this matcher
* @return This matcher
* @throws IllegalArgumentException
! * If newPattern is {@code null}
* @since 1.5
*/
public Matcher usePattern(Pattern newPattern) {
if (newPattern == null)
throw new IllegalArgumentException("Pattern cannot be null");
*** 442,459 ****
* Returns the start index of the subsequence captured by the given group
* during the previous match operation.
*
* <p> <a href="Pattern.html#cg">Capturing groups</a> are indexed from left
* to right, starting at one. Group zero denotes the entire pattern, so
! * the expression <i>m.</i><tt>start(0)</tt> is equivalent to
! * <i>m.</i><tt>start()</tt>. </p>
*
* @param group
* The index of a capturing group in this matcher's pattern
*
* @return The index of the first character captured by the group,
! * or <tt>-1</tt> if the match was successful but the group
* itself did not match anything
*
* @throws IllegalStateException
* If no match has yet been attempted,
* or if the previous match operation failed
--- 442,459 ----
* Returns the start index of the subsequence captured by the given group
* during the previous match operation.
*
* <p> <a href="Pattern.html#cg">Capturing groups</a> are indexed from left
* to right, starting at one. Group zero denotes the entire pattern, so
! * the expression <i>m.</i>{@code start(0)} is equivalent to
! * <i>m.</i>{@code start()}. </p>
*
* @param group
* The index of a capturing group in this matcher's pattern
*
* @return The index of the first character captured by the group,
! * or {@code -1} if the match was successful but the group
* itself did not match anything
*
* @throws IllegalStateException
* If no match has yet been attempted,
* or if the previous match operation failed
*** 514,531 ****
* Returns the offset after the last character of the subsequence
* captured by the given group during the previous match operation.
*
* <p> <a href="Pattern.html#cg">Capturing groups</a> are indexed from left
* to right, starting at one. Group zero denotes the entire pattern, so
! * the expression <i>m.</i><tt>end(0)</tt> is equivalent to
! * <i>m.</i><tt>end()</tt>. </p>
*
* @param group
* The index of a capturing group in this matcher's pattern
*
* @return The offset after the last character captured by the group,
! * or <tt>-1</tt> if the match was successful
* but the group itself did not match anything
*
* @throws IllegalStateException
* If no match has yet been attempted,
* or if the previous match operation failed
--- 514,531 ----
* Returns the offset after the last character of the subsequence
* captured by the given group during the previous match operation.
*
* <p> <a href="Pattern.html#cg">Capturing groups</a> are indexed from left
* to right, starting at one. Group zero denotes the entire pattern, so
! * the expression <i>m.</i>{@code end(0)} is equivalent to
! * <i>m.</i>{@code end()}. </p>
*
* @param group
* The index of a capturing group in this matcher's pattern
*
* @return The offset after the last character captured by the group,
! * or {@code -1} if the match was successful
* but the group itself did not match anything
*
* @throws IllegalStateException
* If no match has yet been attempted,
* or if the previous match operation failed
*** 569,583 ****
/**
* Returns the input subsequence matched by the previous match.
*
* <p> For a matcher <i>m</i> with input sequence <i>s</i>,
! * the expressions <i>m.</i><tt>group()</tt> and
! * <i>s.</i><tt>substring(</tt><i>m.</i><tt>start(),</tt> <i>m.</i><tt>end())</tt>
* are equivalent. </p>
*
! * <p> Note that some patterns, for example <tt>a*</tt>, match the empty
* string. This method will return the empty string when the pattern
* successfully matches the empty string in the input. </p>
*
* @return The (possibly empty) subsequence matched by the previous match,
* in string form
--- 569,583 ----
/**
* Returns the input subsequence matched by the previous match.
*
* <p> For a matcher <i>m</i> with input sequence <i>s</i>,
! * the expressions <i>m.</i>{@code group()} and
! * <i>s.</i>{@code substring(}<i>m.</i>{@code start(),} <i>m.</i>{@code end())}
* are equivalent. </p>
*
! * <p> Note that some patterns, for example {@code a*}, match the empty
* string. This method will return the empty string when the pattern
* successfully matches the empty string in the input. </p>
*
* @return The (possibly empty) subsequence matched by the previous match,
* in string form
*** 593,622 ****
/**
* Returns the input subsequence captured by the given group during the
* previous match operation.
*
* <p> For a matcher <i>m</i>, input sequence <i>s</i>, and group index
! * <i>g</i>, the expressions <i>m.</i><tt>group(</tt><i>g</i><tt>)</tt> and
! * <i>s.</i><tt>substring(</tt><i>m.</i><tt>start(</tt><i>g</i><tt>),</tt> <i>m.</i><tt>end(</tt><i>g</i><tt>))</tt>
* are equivalent. </p>
*
* <p> <a href="Pattern.html#cg">Capturing groups</a> are indexed from left
* to right, starting at one. Group zero denotes the entire pattern, so
! * the expression <tt>m.group(0)</tt> is equivalent to <tt>m.group()</tt>.
* </p>
*
* <p> If the match was successful but the group specified failed to match
! * any part of the input sequence, then <tt>null</tt> is returned. Note
! * that some groups, for example <tt>(a*)</tt>, match the empty string.
* This method will return the empty string when such a group successfully
* matches the empty string in the input. </p>
*
* @param group
* The index of a capturing group in this matcher's pattern
*
* @return The (possibly empty) subsequence captured by the group
! * during the previous match, or <tt>null</tt> if the group
* failed to match part of the input
*
* @throws IllegalStateException
* If no match has yet been attempted,
* or if the previous match operation failed
--- 593,623 ----
/**
* Returns the input subsequence captured by the given group during the
* previous match operation.
*
* <p> For a matcher <i>m</i>, input sequence <i>s</i>, and group index
! * <i>g</i>, the expressions <i>m.</i>{@code group(}<i>g</i>{@code )} and
! * <i>s.</i>{@code substring(}<i>m.</i>{@code start(}<i>g</i>{@code
! * ),} <i>m.</i>{@code end(}<i>g</i>{@code ))}
* are equivalent. </p>
*
* <p> <a href="Pattern.html#cg">Capturing groups</a> are indexed from left
* to right, starting at one. Group zero denotes the entire pattern, so
! * the expression {@code m.group(0)} is equivalent to {@code m.group()}.
* </p>
*
* <p> If the match was successful but the group specified failed to match
! * any part of the input sequence, then {@code null} is returned. Note
! * that some groups, for example {@code (a*)}, match the empty string.
* This method will return the empty string when such a group successfully
* matches the empty string in the input. </p>
*
* @param group
* The index of a capturing group in this matcher's pattern
*
* @return The (possibly empty) subsequence captured by the group
! * during the previous match, or {@code null} if the group
* failed to match part of the input
*
* @throws IllegalStateException
* If no match has yet been attempted,
* or if the previous match operation failed
*** 639,658 ****
* Returns the input subsequence captured by the given
* <a href="Pattern.html#groupname">named-capturing group</a> during the previous
* match operation.
*
* <p> If the match was successful but the group specified failed to match
! * any part of the input sequence, then <tt>null</tt> is returned. Note
! * that some groups, for example <tt>(a*)</tt>, match the empty string.
* This method will return the empty string when such a group successfully
* matches the empty string in the input. </p>
*
* @param name
* The name of a named-capturing group in this matcher's pattern
*
* @return The (possibly empty) subsequence captured by the named group
! * during the previous match, or <tt>null</tt> if the group
* failed to match part of the input
*
* @throws IllegalStateException
* If no match has yet been attempted,
* or if the previous match operation failed
--- 640,659 ----
* Returns the input subsequence captured by the given
* <a href="Pattern.html#groupname">named-capturing group</a> during the previous
* match operation.
*
* <p> If the match was successful but the group specified failed to match
! * any part of the input sequence, then {@code null} is returned. Note
! * that some groups, for example {@code (a*)}, match the empty string.
* This method will return the empty string when such a group successfully
* matches the empty string in the input. </p>
*
* @param name
* The name of a named-capturing group in this matcher's pattern
*
* @return The (possibly empty) subsequence captured by the named group
! * during the previous match, or {@code null} if the group
* failed to match part of the input
*
* @throws IllegalStateException
* If no match has yet been attempted,
* or if the previous match operation failed
*** 687,699 ****
/**
* Attempts to match the entire region against the pattern.
*
* <p> If the match succeeds then more information can be obtained via the
! * <tt>start</tt>, <tt>end</tt>, and <tt>group</tt> methods. </p>
*
! * @return <tt>true</tt> if, and only if, the entire region sequence
* matches this matcher's pattern
*/
public boolean matches() {
return match(from, ENDANCHOR);
}
--- 688,700 ----
/**
* Attempts to match the entire region against the pattern.
*
* <p> If the match succeeds then more information can be obtained via the
! * {@code start}, {@code end}, and {@code group} methods. </p>
*
! * @return {@code true} if, and only if, the entire region sequence
* matches this matcher's pattern
*/
public boolean matches() {
return match(from, ENDANCHOR);
}
*** 706,718 ****
* a previous invocation of the method was successful and the matcher has
* not since been reset, at the first character not matched by the previous
* match.
*
* <p> If the match succeeds then more information can be obtained via the
! * <tt>start</tt>, <tt>end</tt>, and <tt>group</tt> methods. </p>
*
! * @return <tt>true</tt> if, and only if, a subsequence of the input
* sequence matches this matcher's pattern
*/
public boolean find() {
int nextSearchIndex = last;
if (nextSearchIndex == first)
--- 707,719 ----
* a previous invocation of the method was successful and the matcher has
* not since been reset, at the first character not matched by the previous
* match.
*
* <p> If the match succeeds then more information can be obtained via the
! * {@code start}, {@code end}, and {@code group} methods. </p>
*
! * @return {@code true} if, and only if, a subsequence of the input
* sequence matches this matcher's pattern
*/
public boolean find() {
int nextSearchIndex = last;
if (nextSearchIndex == first)
*** 735,754 ****
* Resets this matcher and then attempts to find the next subsequence of
* the input sequence that matches the pattern, starting at the specified
* index.
*
* <p> If the match succeeds then more information can be obtained via the
! * <tt>start</tt>, <tt>end</tt>, and <tt>group</tt> methods, and subsequent
* invocations of the {@link #find()} method will start at the first
* character not matched by this match. </p>
*
* @param start the index to start searching for a match
* @throws IndexOutOfBoundsException
* If start is less than zero or if start is greater than the
* length of the input sequence.
*
! * @return <tt>true</tt> if, and only if, a subsequence of the input
* sequence starting at the given index matches this matcher's
* pattern
*/
public boolean find(int start) {
int limit = getTextLength();
--- 736,755 ----
* Resets this matcher and then attempts to find the next subsequence of
* the input sequence that matches the pattern, starting at the specified
* index.
*
* <p> If the match succeeds then more information can be obtained via the
! * {@code start}, {@code end}, and {@code group} methods, and subsequent
* invocations of the {@link #find()} method will start at the first
* character not matched by this match. </p>
*
* @param start the index to start searching for a match
* @throws IndexOutOfBoundsException
* If start is less than zero or if start is greater than the
* length of the input sequence.
*
! * @return {@code true} if, and only if, a subsequence of the input
* sequence starting at the given index matches this matcher's
* pattern
*/
public boolean find(int start) {
int limit = getTextLength();
*** 765,792 ****
* <p> Like the {@link #matches matches} method, this method always starts
* at the beginning of the region; unlike that method, it does not
* require that the entire region be matched.
*
* <p> If the match succeeds then more information can be obtained via the
! * <tt>start</tt>, <tt>end</tt>, and <tt>group</tt> methods. </p>
*
! * @return <tt>true</tt> if, and only if, a prefix of the input
* sequence matches this matcher's pattern
*/
public boolean lookingAt() {
return match(from, NOANCHOR);
}
/**
! * Returns a literal replacement <code>String</code> for the specified
! * <code>String</code>.
*
! * This method produces a <code>String</code> that will work
! * as a literal replacement <code>s</code> in the
! * <code>appendReplacement</code> method of the {@link Matcher} class.
! * The <code>String</code> produced will match the sequence of characters
! * in <code>s</code> treated as a literal sequence. Slashes ('\') and
* dollar signs ('$') will be given no special meaning.
*
* @param s The string to be literalized
* @return A literal string replacement
* @since 1.5
--- 766,793 ----
* <p> Like the {@link #matches matches} method, this method always starts
* at the beginning of the region; unlike that method, it does not
* require that the entire region be matched.
*
* <p> If the match succeeds then more information can be obtained via the
! * {@code start}, {@code end}, and {@code group} methods. </p>
*
! * @return {@code true} if, and only if, a prefix of the input
* sequence matches this matcher's pattern
*/
public boolean lookingAt() {
return match(from, NOANCHOR);
}
/**
! * Returns a literal replacement {@code String} for the specified
! * {@code String}.
*
! * This method produces a {@code String} that will work
! * as a literal replacement {@code s} in the
! * {@code appendReplacement} method of the {@link Matcher} class.
! * The {@code String} produced will match the sequence of characters
! * in {@code s} treated as a literal sequence. Slashes ('\') and
* dollar signs ('$') will be given no special meaning.
*
* @param s The string to be literalized
* @return A literal string replacement
* @since 1.5
*** 814,824 ****
*
* <li><p> It reads characters from the input sequence, starting at the
* append position, and appends them to the given string buffer. It
* stops after reading the last character preceding the previous match,
* that is, the character at index {@link
! * #start()} <tt>-</tt> <tt>1</tt>. </p></li>
*
* <li><p> It appends the given replacement string to the string buffer.
* </p></li>
*
* <li><p> It sets the append position of this matcher to the index of
--- 815,825 ----
*
* <li><p> It reads characters from the input sequence, starting at the
* append position, and appends them to the given string buffer. It
* stops after reading the last character preceding the previous match,
* that is, the character at index {@link
! * #start()} {@code -} {@code 1}. </p></li>
*
* <li><p> It appends the given replacement string to the string buffer.
* </p></li>
*
* <li><p> It sets the append position of this matcher to the index of
*** 827,861 ****
*
* </ol>
*
* <p> The replacement string may contain references to subsequences
* captured during the previous match: Each occurrence of
! * <tt>${</tt><i>name</i><tt>}</tt> or <tt>$</tt><i>g</i>
* will be replaced by the result of evaluating the corresponding
* {@link #group(String) group(name)} or {@link #group(int) group(g)}
! * respectively. For <tt>$</tt><i>g</i>,
! * the first number after the <tt>$</tt> is always treated as part of
* the group reference. Subsequent numbers are incorporated into g if
* they would form a legal group reference. Only the numerals '0'
* through '9' are considered as potential components of the group
! * reference. If the second group matched the string <tt>"foo"</tt>, for
! * example, then passing the replacement string <tt>"$2bar"</tt> would
! * cause <tt>"foobar"</tt> to be appended to the string buffer. A dollar
! * sign (<tt>$</tt>) may be included as a literal in the replacement
! * string by preceding it with a backslash (<tt>\$</tt>).
*
! * <p> Note that backslashes (<tt>\</tt>) and dollar signs (<tt>$</tt>) in
* the replacement string may cause the results to be different than if it
* were being treated as a literal replacement string. Dollar signs may be
* treated as references to captured subsequences as described above, and
* backslashes are used to escape literal characters in the replacement
* string.
*
* <p> This method is intended to be used in a loop together with the
* {@link #appendTail appendTail} and {@link #find find} methods. The
! * following code, for example, writes <tt>one dog two dogs in the
! * yard</tt> to the standard-output stream: </p>
*
* <blockquote><pre>
* Pattern p = Pattern.compile("cat");
* Matcher m = p.matcher("one cat two cats in the yard");
* StringBuffer sb = new StringBuffer();
--- 828,862 ----
*
* </ol>
*
* <p> The replacement string may contain references to subsequences
* captured during the previous match: Each occurrence of
! * <code>${</code><i>name</i><code>}</code> or {@code $}<i>g</i>
* will be replaced by the result of evaluating the corresponding
* {@link #group(String) group(name)} or {@link #group(int) group(g)}
! * respectively. For {@code $}<i>g</i>,
! * the first number after the {@code $} is always treated as part of
* the group reference. Subsequent numbers are incorporated into g if
* they would form a legal group reference. Only the numerals '0'
* through '9' are considered as potential components of the group
! * reference. If the second group matched the string {@code "foo"}, for
! * example, then passing the replacement string {@code "$2bar"} would
! * cause {@code "foobar"} to be appended to the string buffer. A dollar
! * sign ({@code $}) may be included as a literal in the replacement
! * string by preceding it with a backslash ({@code \$}).
*
! * <p> Note that backslashes ({@code \}) and dollar signs ({@code $}) in
* the replacement string may cause the results to be different than if it
* were being treated as a literal replacement string. Dollar signs may be
* treated as references to captured subsequences as described above, and
* backslashes are used to escape literal characters in the replacement
* string.
*
* <p> This method is intended to be used in a loop together with the
* {@link #appendTail appendTail} and {@link #find find} methods. The
! * following code, for example, writes {@code one dog two dogs in the
! * yard} to the standard-output stream: </p>
*
* <blockquote><pre>
* Pattern p = Pattern.compile("cat");
* Matcher m = p.matcher("one cat two cats in the yard");
* StringBuffer sb = new StringBuffer();
*** 909,919 ****
*
* <li><p> It reads characters from the input sequence, starting at the
* append position, and appends them to the given string builder. It
* stops after reading the last character preceding the previous match,
* that is, the character at index {@link
! * #start()} <tt>-</tt> <tt>1</tt>. </p></li>
*
* <li><p> It appends the given replacement string to the string builder.
* </p></li>
*
* <li><p> It sets the append position of this matcher to the index of
--- 910,920 ----
*
* <li><p> It reads characters from the input sequence, starting at the
* append position, and appends them to the given string builder. It
* stops after reading the last character preceding the previous match,
* that is, the character at index {@link
! * #start()} {@code -} {@code 1}. </p></li>
*
* <li><p> It appends the given replacement string to the string builder.
* </p></li>
*
* <li><p> It sets the append position of this matcher to the index of
*** 922,954 ****
*
* </ol>
*
* <p> The replacement string may contain references to subsequences
* captured during the previous match: Each occurrence of
! * <tt>$</tt><i>g</i> will be replaced by the result of
! * evaluating {@link #group(int) group}<tt>(</tt><i>g</i><tt>)</tt>.
! * The first number after the <tt>$</tt> is always treated as part of
* the group reference. Subsequent numbers are incorporated into g if
* they would form a legal group reference. Only the numerals '0'
* through '9' are considered as potential components of the group
! * reference. If the second group matched the string <tt>"foo"</tt>, for
! * example, then passing the replacement string <tt>"$2bar"</tt> would
! * cause <tt>"foobar"</tt> to be appended to the string builder. A dollar
! * sign (<tt>$</tt>) may be included as a literal in the replacement
! * string by preceding it with a backslash (<tt>\$</tt>).
*
! * <p> Note that backslashes (<tt>\</tt>) and dollar signs (<tt>$</tt>) in
* the replacement string may cause the results to be different than if it
* were being treated as a literal replacement string. Dollar signs may be
* treated as references to captured subsequences as described above, and
* backslashes are used to escape literal characters in the replacement
* string.
*
* <p> This method is intended to be used in a loop together with the
* {@link #appendTail appendTail} and {@link #find find} methods. The
! * following code, for example, writes <tt>one dog two dogs in the
! * yard</tt> to the standard-output stream: </p>
*
* <blockquote><pre>
* Pattern p = Pattern.compile("cat");
* Matcher m = p.matcher("one cat two cats in the yard");
* StringBuilder sb = new StringBuilder();
--- 923,955 ----
*
* </ol>
*
* <p> The replacement string may contain references to subsequences
* captured during the previous match: Each occurrence of
! * {@code $}<i>g</i> will be replaced by the result of
! * evaluating {@link #group(int) group}{@code (}<i>g</i>{@code )}.
! * The first number after the {@code $} is always treated as part of
* the group reference. Subsequent numbers are incorporated into g if
* they would form a legal group reference. Only the numerals '0'
* through '9' are considered as potential components of the group
! * reference. If the second group matched the string {@code "foo"}, for
! * example, then passing the replacement string {@code "$2bar"} would
! * cause {@code "foobar"} to be appended to the string builder. A dollar
! * sign ({@code $}) may be included as a literal in the replacement
! * string by preceding it with a backslash ({@code \$}).
*
! * <p> Note that backslashes ({@code \}) and dollar signs ({@code $}) in
* the replacement string may cause the results to be different than if it
* were being treated as a literal replacement string. Dollar signs may be
* treated as references to captured subsequences as described above, and
* backslashes are used to escape literal characters in the replacement
* string.
*
* <p> This method is intended to be used in a loop together with the
* {@link #appendTail appendTail} and {@link #find find} methods. The
! * following code, for example, writes {@code one dog two dogs in the
! * yard} to the standard-output stream: </p>
*
* <blockquote><pre>
* Pattern p = Pattern.compile("cat");
* Matcher m = p.matcher("one cat two cats in the yard");
* StringBuilder sb = new StringBuilder();
*** 1132,1152 ****
* part of any match are appended directly to the result string; each match
* is replaced in the result by the replacement string. The replacement
* string may contain references to captured subsequences as in the {@link
* #appendReplacement appendReplacement} method.
*
! * <p> Note that backslashes (<tt>\</tt>) and dollar signs (<tt>$</tt>) in
* the replacement string may cause the results to be different than if it
* were being treated as a literal replacement string. Dollar signs may be
* treated as references to captured subsequences as described above, and
* backslashes are used to escape literal characters in the replacement
* string.
*
! * <p> Given the regular expression <tt>a*b</tt>, the input
! * <tt>"aabfooaabfooabfoob"</tt>, and the replacement string
! * <tt>"-"</tt>, an invocation of this method on a matcher for that
! * expression would yield the string <tt>"-foo-foo-foo-"</tt>.
*
* <p> Invoking this method changes this matcher's state. If the matcher
* is to be used in further matching operations then it should first be
* reset. </p>
*
--- 1133,1153 ----
* part of any match are appended directly to the result string; each match
* is replaced in the result by the replacement string. The replacement
* string may contain references to captured subsequences as in the {@link
* #appendReplacement appendReplacement} method.
*
! * <p> Note that backslashes ({@code \}) and dollar signs ({@code $}) in
* the replacement string may cause the results to be different than if it
* were being treated as a literal replacement string. Dollar signs may be
* treated as references to captured subsequences as described above, and
* backslashes are used to escape literal characters in the replacement
* string.
*
! * <p> Given the regular expression {@code a*b}, the input
! * {@code "aabfooaabfooabfoob"}, and the replacement string
! * {@code "-"}, an invocation of this method on a matcher for that
! * expression would yield the string {@code "-foo-foo-foo-"}.
*
* <p> Invoking this method changes this matcher's state. If the matcher
* is to be used in further matching operations then it should first be
* reset. </p>
*
*** 1184,1205 ****
* is replaced in the result by the applying the replacer function that
* returns a replacement string. Each replacement string may contain
* references to captured subsequences as in the {@link #appendReplacement
* appendReplacement} method.
*
! * <p> Note that backslashes (<tt>\</tt>) and dollar signs (<tt>$</tt>) in
* a replacement string may cause the results to be different than if it
* were being treated as a literal replacement string. Dollar signs may be
* treated as references to captured subsequences as described above, and
* backslashes are used to escape literal characters in the replacement
* string.
*
! * <p> Given the regular expression <tt>dog</tt>, the input
! * <tt>"zzzdogzzzdogzzz"</tt>, and the function
* {@code mr -> mr.group().toUpperCase()}, an invocation of this method on
* a matcher for that expression would yield the string
! * <tt>"zzzDOGzzzDOGzzz"</tt>.
*
* <p> Invoking this method changes this matcher's state. If the matcher
* is to be used in further matching operations then it should first be
* reset. </p>
*
--- 1185,1206 ----
* is replaced in the result by the applying the replacer function that
* returns a replacement string. Each replacement string may contain
* references to captured subsequences as in the {@link #appendReplacement
* appendReplacement} method.
*
! * <p> Note that backslashes ({@code \}) and dollar signs ({@code $}) in
* a replacement string may cause the results to be different than if it
* were being treated as a literal replacement string. Dollar signs may be
* treated as references to captured subsequences as described above, and
* backslashes are used to escape literal characters in the replacement
* string.
*
! * <p> Given the regular expression {@code dog}, the input
! * {@code "zzzdogzzzdogzzz"}, and the function
* {@code mr -> mr.group().toUpperCase()}, an invocation of this method on
* a matcher for that expression would yield the string
! * {@code "zzzDOGzzzDOGzzz"}.
*
* <p> Invoking this method changes this matcher's state. If the matcher
* is to be used in further matching operations then it should first be
* reset. </p>
*
*** 1358,1378 ****
* part of the match are appended directly to the result string; the match
* is replaced in the result by the replacement string. The replacement
* string may contain references to captured subsequences as in the {@link
* #appendReplacement appendReplacement} method.
*
! * <p>Note that backslashes (<tt>\</tt>) and dollar signs (<tt>$</tt>) in
* the replacement string may cause the results to be different than if it
* were being treated as a literal replacement string. Dollar signs may be
* treated as references to captured subsequences as described above, and
* backslashes are used to escape literal characters in the replacement
* string.
*
! * <p> Given the regular expression <tt>dog</tt>, the input
! * <tt>"zzzdogzzzdogzzz"</tt>, and the replacement string
! * <tt>"cat"</tt>, an invocation of this method on a matcher for that
! * expression would yield the string <tt>"zzzcatzzzdogzzz"</tt>. </p>
*
* <p> Invoking this method changes this matcher's state. If the matcher
* is to be used in further matching operations then it should first be
* reset. </p>
*
--- 1359,1379 ----
* part of the match are appended directly to the result string; the match
* is replaced in the result by the replacement string. The replacement
* string may contain references to captured subsequences as in the {@link
* #appendReplacement appendReplacement} method.
*
! * <p>Note that backslashes ({@code \}) and dollar signs ({@code $}) in
* the replacement string may cause the results to be different than if it
* were being treated as a literal replacement string. Dollar signs may be
* treated as references to captured subsequences as described above, and
* backslashes are used to escape literal characters in the replacement
* string.
*
! * <p> Given the regular expression {@code dog}, the input
! * {@code "zzzdogzzzdogzzz"}, and the replacement string
! * {@code "cat"}, an invocation of this method on a matcher for that
! * expression would yield the string {@code "zzzcatzzzdogzzz"}. </p>
*
* <p> Invoking this method changes this matcher's state. If the matcher
* is to be used in further matching operations then it should first be
* reset. </p>
*
*** 1406,1427 ****
* is replaced in the result by the applying the replacer function that
* returns a replacement string. The replacement string may contain
* references to captured subsequences as in the {@link #appendReplacement
* appendReplacement} method.
*
! * <p>Note that backslashes (<tt>\</tt>) and dollar signs (<tt>$</tt>) in
* the replacement string may cause the results to be different than if it
* were being treated as a literal replacement string. Dollar signs may be
* treated as references to captured subsequences as described above, and
* backslashes are used to escape literal characters in the replacement
* string.
*
! * <p> Given the regular expression <tt>dog</tt>, the input
! * <tt>"zzzdogzzzdogzzz"</tt>, and the function
* {@code mr -> mr.group().toUpperCase()}, an invocation of this method on
* a matcher for that expression would yield the string
! * <tt>"zzzDOGzzzdogzzz"</tt>.
*
* <p> Invoking this method changes this matcher's state. If the matcher
* is to be used in further matching operations then it should first be
* reset.
*
--- 1407,1428 ----
* is replaced in the result by the applying the replacer function that
* returns a replacement string. The replacement string may contain
* references to captured subsequences as in the {@link #appendReplacement
* appendReplacement} method.
*
! * <p>Note that backslashes ({@code \}) and dollar signs ({@code $}) in
* the replacement string may cause the results to be different than if it
* were being treated as a literal replacement string. Dollar signs may be
* treated as references to captured subsequences as described above, and
* backslashes are used to escape literal characters in the replacement
* string.
*
! * <p> Given the regular expression {@code dog}, the input
! * {@code "zzzdogzzzdogzzz"}, and the function
* {@code mr -> mr.group().toUpperCase()}, an invocation of this method on
* a matcher for that expression would yield the string
! * {@code "zzzDOGzzzdogzzz"}.
*
* <p> Invoking this method changes this matcher's state. If the matcher
* is to be used in further matching operations then it should first be
* reset.
*
*** 1469,1480 ****
/**
* Sets the limits of this matcher's region. The region is the part of the
* input sequence that will be searched to find a match. Invoking this
* method resets the matcher, and then sets the region to start at the
! * index specified by the <code>start</code> parameter and end at the
! * index specified by the <code>end</code> parameter.
*
* <p>Depending on the transparency and anchoring being used (see
* {@link #useTransparentBounds useTransparentBounds} and
* {@link #useAnchoringBounds useAnchoringBounds}), certain constructs such
* as anchors may behave differently at or around the boundaries of the
--- 1470,1481 ----
/**
* Sets the limits of this matcher's region. The region is the part of the
* input sequence that will be searched to find a match. Invoking this
* method resets the matcher, and then sets the region to start at the
! * index specified by the {@code start} parameter and end at the
! * index specified by the {@code end} parameter.
*
* <p>Depending on the transparency and anchoring being used (see
* {@link #useTransparentBounds useTransparentBounds} and
* {@link #useAnchoringBounds useAnchoringBounds}), certain constructs such
* as anchors may behave differently at or around the boundaries of the
*** 1532,1565 ****
}
/**
* Queries the transparency of region bounds for this matcher.
*
! * <p> This method returns <tt>true</tt> if this matcher uses
! * <i>transparent</i> bounds, <tt>false</tt> if it uses <i>opaque</i>
* bounds.
*
* <p> See {@link #useTransparentBounds useTransparentBounds} for a
* description of transparent and opaque bounds.
*
* <p> By default, a matcher uses opaque region boundaries.
*
! * @return <tt>true</tt> iff this matcher is using transparent bounds,
! * <tt>false</tt> otherwise.
* @see java.util.regex.Matcher#useTransparentBounds(boolean)
* @since 1.5
*/
public boolean hasTransparentBounds() {
return transparentBounds;
}
/**
* Sets the transparency of region bounds for this matcher.
*
! * <p> Invoking this method with an argument of <tt>true</tt> will set this
* matcher to use <i>transparent</i> bounds. If the boolean
! * argument is <tt>false</tt>, then <i>opaque</i> bounds will be used.
*
* <p> Using transparent bounds, the boundaries of this
* matcher's region are transparent to lookahead, lookbehind,
* and boundary matching constructs. Those constructs can see beyond the
* boundaries of the region to see if a match is appropriate.
--- 1533,1566 ----
}
/**
* Queries the transparency of region bounds for this matcher.
*
! * <p> This method returns {@code true} if this matcher uses
! * <i>transparent</i> bounds, {@code false} if it uses <i>opaque</i>
* bounds.
*
* <p> See {@link #useTransparentBounds useTransparentBounds} for a
* description of transparent and opaque bounds.
*
* <p> By default, a matcher uses opaque region boundaries.
*
! * @return {@code true} iff this matcher is using transparent bounds,
! * {@code false} otherwise.
* @see java.util.regex.Matcher#useTransparentBounds(boolean)
* @since 1.5
*/
public boolean hasTransparentBounds() {
return transparentBounds;
}
/**
* Sets the transparency of region bounds for this matcher.
*
! * <p> Invoking this method with an argument of {@code true} will set this
* matcher to use <i>transparent</i> bounds. If the boolean
! * argument is {@code false}, then <i>opaque</i> bounds will be used.
*
* <p> Using transparent bounds, the boundaries of this
* matcher's region are transparent to lookahead, lookbehind,
* and boundary matching constructs. Those constructs can see beyond the
* boundaries of the region to see if a match is appropriate.
*** 1584,1616 ****
}
/**
* Queries the anchoring of region bounds for this matcher.
*
! * <p> This method returns <tt>true</tt> if this matcher uses
! * <i>anchoring</i> bounds, <tt>false</tt> otherwise.
*
* <p> See {@link #useAnchoringBounds useAnchoringBounds} for a
* description of anchoring bounds.
*
* <p> By default, a matcher uses anchoring region boundaries.
*
! * @return <tt>true</tt> iff this matcher is using anchoring bounds,
! * <tt>false</tt> otherwise.
* @see java.util.regex.Matcher#useAnchoringBounds(boolean)
* @since 1.5
*/
public boolean hasAnchoringBounds() {
return anchoringBounds;
}
/**
* Sets the anchoring of region bounds for this matcher.
*
! * <p> Invoking this method with an argument of <tt>true</tt> will set this
* matcher to use <i>anchoring</i> bounds. If the boolean
! * argument is <tt>false</tt>, then <i>non-anchoring</i> bounds will be
* used.
*
* <p> Using anchoring bounds, the boundaries of this
* matcher's region match anchors such as ^ and $.
*
--- 1585,1617 ----
}
/**
* Queries the anchoring of region bounds for this matcher.
*
! * <p> This method returns {@code true} if this matcher uses
! * <i>anchoring</i> bounds, {@code false} otherwise.
*
* <p> See {@link #useAnchoringBounds useAnchoringBounds} for a
* description of anchoring bounds.
*
* <p> By default, a matcher uses anchoring region boundaries.
*
! * @return {@code true} iff this matcher is using anchoring bounds,
! * {@code false} otherwise.
* @see java.util.regex.Matcher#useAnchoringBounds(boolean)
* @since 1.5
*/
public boolean hasAnchoringBounds() {
return anchoringBounds;
}
/**
* Sets the anchoring of region bounds for this matcher.
*
! * <p> Invoking this method with an argument of {@code true} will set this
* matcher to use <i>anchoring</i> bounds. If the boolean
! * argument is {@code false}, then <i>non-anchoring</i> bounds will be
* used.
*
* <p> Using anchoring bounds, the boundaries of this
* matcher's region match anchors such as ^ and $.
*
*** 1629,1639 ****
return this;
}
/**
* <p>Returns the string representation of this matcher. The
! * string representation of a <code>Matcher</code> contains information
* that may be useful for debugging. The exact format is unspecified.
*
* @return The string representation of this matcher
* @since 1.5
*/
--- 1630,1640 ----
return this;
}
/**
* <p>Returns the string representation of this matcher. The
! * string representation of a {@code Matcher} contains information
* that may be useful for debugging. The exact format is unspecified.
*
* @return The string representation of this matcher
* @since 1.5
*/
< prev index next >