Interface RE.Match

All Superinterfaces:
CharSequence, RE.MatchGroup
Enclosing interface:
RE

public static interface RE.Match extends RE.MatchGroup
The result of a matched group after a successful find, matches, or lookingAt operation.
  • Method Details

    • getGroups

      Map<String, RE.MatchGroup> getGroups()
      Get the matching groups. This will only return the groups that were captured.
    • getGroupValues

      Map<String,String> getGroupValues()
      Get the matching groups with their value. This will only return the values that were actually captured.
    • group

      Get a group by name. This will throw an exception if the group was not defined in this regular expression. It will return an Optional.empty() when the group wasn't captured.
      Parameters:
      name - the name of the group
    • take

      default String take(RE expected)
      This Match has a rover in its the matching region. This method requires the expected to match against the current position or it will throw an exception. It will move the rover forward to after the match. It will skip any whitespace before it matches.
      Parameters:
      expected - the expected match
      Returns:
      the value of the match
    • skip

      default void skip(RE skip)
      This Match has a rover in its the matching region. This method requires the skip to match against the current position or it will throw an exception. It will move the rover forward to after the match.
      Parameters:
      skip - the RE to skip
    • check

      default boolean check(RE expected)
      This Match has a rover its the matching region. This method will see if the current position matches the RE. If it does, the rover will be moved forward. Otherwise it stays where it is. It will skip any whitespace before it matches.
      Parameters:
      expected - the expected value
      Returns:
      true if there was a match and the match was consumed
    • tryMatch

      String tryMatch(RE match)
      This Match has a rover in its the matching region. This method tries too see if the string from this rover to the end of this match, matches the match parameter. If so, it returns the value and moves the rover forward.
      Parameters:
      match - the RE to match return a string when matched or null
    • group

      Optional<RE.MatchGroup> group(int group)
    • presentGroup

      String presentGroup(String groupName)
      This gets the value of a group but throws an exception of the group is not there.
      Parameters:
      groupName - the name of the group