Interface RegexMatcher
- All Superinterfaces:
ContinuousMatcher
,InlineMatcher
- All Known Implementing Classes:
RegexMatcher.ChatStandard
,RegexMatcher.Simple
,RegexMatcher.Standard
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:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
static class
A helper class for constructing a RegexMatcher from just a regex pattern and a getMatch function.static class
A helper class for regex matchers of the form[namespace:input]
.Nested classes/interfaces inherited from interface com.samsthenerd.inline.api.matching.ContinuousMatcher
ContinuousMatcher.ContinuousMatchResult
-
Method Summary
Modifier and TypeMethodDescriptiongetMatch
(MatchResult regexMatch, MatchContext matchContext) Parses an InlineMatch out of the regexMatch.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.getRegex()
match
(String input, MatchContext matchContext) Methods inherited from interface com.samsthenerd.inline.api.matching.ContinuousMatcher
match
Methods inherited from interface com.samsthenerd.inline.api.matching.InlineMatcher
getId, getInfo
-
Method Details
-
match
- Specified by:
match
in interfaceContinuousMatcher
-
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 togetMatch(java.util.regex.MatchResult, com.samsthenerd.inline.api.matching.MatchContext)
and cover the entire regex match.- Parameters:
regexMatch
- a single match from the provided regexmatchContext
- 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
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
-