Interface RegexMatcher

All Superinterfaces:
ContinuousMatcher, InlineMatcher
All Known Implementing Classes:
RegexMatcher.ChatStandard, RegexMatcher.Simple, RegexMatcher.Standard

public interface RegexMatcher extends ContinuousMatcher
A regex based matcher. Simply implement getRegex() and getMatch(java.util.regex.MatchResult, com.samsthenerd.inline.api.matching.MatchContext) and it'll take care of the rest.
See Also:
  • Method Details

    • match

      default ContinuousMatcher.ContinuousMatchResult match(String input, MatchContext matchContext)
      Specified by:
      match in interface ContinuousMatcher
    • getRegex

      Pattern getRegex()
    • getMatchAndGroup

      @NotNull default @NotNull net.minecraft.util.Pair<InlineMatch,Integer> getMatchAndGroup(MatchResult regexMatch, MatchContext matchContext)
      Parses an InlineMatch out of the regexMatch and provides a group from the regexMatch for this match to be attached to. By default this will delegate to getMatch(java.util.regex.MatchResult, com.samsthenerd.inline.api.matching.MatchContext) and cover the entire regex match.
      Parameters:
      regexMatch - a single match from the provided regex
      matchContext - a match context provided in-case it's needed. It generally won't be.
      Returns:
      Pair of InlineMatch and the regex match group to attach it to. The match may be null, but the pair should not be.
    • getMatch

      @Nullable InlineMatch getMatch(MatchResult regexMatch, MatchContext matchContext)
      Parses an InlineMatch out of the regexMatch.
      Parameters:
      regexMatch - a single match from the provided regex.
      matchContext - a match context provided in-case it's needed. It generally won't be.
      Returns:
      InlineMatch that gets attached to the entire regex match or null for no match