Package com.google.code.regexp
Interface MatchResult
- All Superinterfaces:
MatchResult
- All Known Implementing Classes:
Matcher
The result of a match operation.
This interface contains query methods used to determine the results of a match against a regular expression. The match boundaries, groups and group boundaries can be seen but not modified through a MatchResult.
- Since:
- 0.1.9
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the offset after the last character of the subsequence captured by the given group during this match.Returns the input subsequence captured by the given group during the previous match operation.Returns a map of the pattern's named groups and indexes within the pattern.Finds all named groups that exist in the input stringReturns the named capture groups in orderint
Returns the start index of the subsequence captured by the given group during this match.Methods inherited from interface java.util.regex.MatchResult
end, end, group, group, groupCount, start, start
-
Method Details
-
orderedGroups
Returns the named capture groups in order- Returns:
- the named capture groups
-
namedGroupsList
Finds all named groups that exist in the input string- Returns:
- a list of maps, each containing name-value matches (empty if no match found). Example: pattern: (?<dote>\d+).(?<day>\w+) input: 1 Sun foo bar 2 Mon foo output: [{"date":"1", "day":"Sun"}, {"date":"2", "day":"Mon"}]
- Since:
- 1.0.0
-
namedGroups
Returns a map of the pattern's named groups and indexes within the pattern.- Returns:
- an unmodifiable map of group names to 1-based indexes (empty if named groups not found). Example: pattern: (a)(b)(?<group1>x)(c)(?<group2>y) output: {"group1": 3, "group2": 5}
- Since:
- 1.0.0
-
group
Returns the input subsequence captured by the given group during the previous match operation.- Parameters:
groupName
- name of capture group- Returns:
- the subsequence
-
start
Returns the start index of the subsequence captured by the given group during this match.- Parameters:
groupName
- name of capture group- Returns:
- the index
-
end
Returns the offset after the last character of the subsequence captured by the given group during this match.- Parameters:
groupName
- name of capture group- Returns:
- the offset
-