public class RegexMatcher extends Object
java.util.regex.Matcher
. The main methods of this class are:
getPatternName()
method which returns the name of the pattern defined in the RegexCollection
which is associated with this patterngetPattern()
method which returns the RegexPattern
defined in the RegexCollection
which is associated with this patterngetMatcher()
method which returns the underlying MatcherModifier and Type | Method and Description |
---|---|
int |
end()
Returns the offset after the last character matched.
|
int |
end(int group)
Returns the offset after the last character of the subsequence captured by the given group during the previous match operation.
|
int |
end(String name)
Returns the offset after the last character of the subsequence captured by the given named-capturing group during the previous match operation.
|
boolean |
find()
Attempts to find the next subsequence of the input sequence that matches the pattern.
|
boolean |
find(int start)
Resets this matcher and then attempts to find the next subsequence of the input sequence that matches the pattern, starting at the specified index.
|
Matcher |
getMatcher()
The matcher.
|
RegexPattern |
getPattern()
The pattern.
|
String |
getPatternName()
The pattern name.
|
String |
group()
Returns the input subsequence matched by the previous match.
|
String |
group(int group)
Returns the input subsequence captured by the given group during the previous match operation.
|
String |
group(String name)
Returns the input subsequence captured by the given capturing group during the previous match operation.
|
int |
groupCount()
Returns the number of capturing groups in this matcher's pattern.
|
boolean |
matches()
Attempts to match the underying matcher region against the pattern.
|
int |
start()
Returns the start index of the previous match.
|
int |
start(int group)
Returns the start index of the subsequence captured by the given group during the previous match operation.
|
int |
start(String name)
Returns the start index of the subsequence captured by the given named-capturing group during the previous match operation.
|
public RegexPattern getPattern()
public String getPatternName()
public Matcher getMatcher()
public boolean matches()
public String group()
IllegalStateException
- If no match has yet been attempted, or if the previous match operation failedpublic String group(int group)
group
- The index of a capturing group in this matcher's patternIllegalStateException
- If no match has yet been attempted, or if the previous match operation failedIndexOutOfBoundsException
- If there is no capturing group in the pattern with the given indexpublic String group(String name)
name
- The name of a named-capturing group in this matcher's patternIllegalStateException
- If no match has yet been attempted, or if the previous match operation failedIllegalArgumentException
- If there is no capturing group in the pattern with the given namepublic int groupCount()
public boolean find()
public boolean find(int start)
start
- the index to start searching for a matchIndexOutOfBoundsException
- If start is less than zero or if start is greater than the length of the input sequence.public int end()
IllegalStateException
- If no match has yet been attempted, or if the previous match operation failedpublic int start()
IllegalStateException
- If no match has yet been attempted, or if the previous match operation failedpublic int start(int group)
group
- The index of a capturing group in this matcher's patternIllegalStateException
- If no match has yet been attempted, or if the previous match operation failedIndexOutOfBoundsException
- If there is no capturing group in the pattern with the given indexpublic int start(String name)
name
- The name of a named-capturing group in this matcher's patternIllegalStateException
- If no match has yet been attempted, or if the previous match operation failedIllegalArgumentException
- If there is no capturing group in the pattern with the given namepublic int end(int group)
group
- The index of a capturing group in this matcher's patternIllegalStateException
- If no match has yet been attempted, or if the previous match operation failedIndexOutOfBoundsException
- If there is no capturing group in the pattern with the given indexpublic int end(String name)
name
- The name of a named-capturing group in this matcher's patternIllegalStateException
- If no match has yet been attempted, or if the previous match operation failedIllegalArgumentException
- If there is no capturing group in the pattern with the given name