Interface MatchResult

All Superinterfaces:
MatchResult
All Known Implementing Classes:
Matcher

public interface MatchResult extends MatchResult
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 Type
    Method
    Description
    int
    end(String groupName)
    Returns the offset after the last character of the subsequence captured by the given group during this match.
    group(String groupName)
    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 string
    Returns the named capture groups in order
    int
    start(String groupName)
    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

      List<String> orderedGroups()
      Returns the named capture groups in order
      Returns:
      the named capture groups
    • namedGroupsList

      List<Map<String,String>> 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

      Map<String,Integer> 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

      String group(String groupName)
      Returns the input subsequence captured by the given group during the previous match operation.
      Parameters:
      groupName - name of capture group
      Returns:
      the subsequence
    • start

      int start(String groupName)
      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

      int end(String groupName)
      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