Class RegexMatcher.Standard
java.lang.Object
com.samsthenerd.inline.api.matching.RegexMatcher.Standard
- All Implemented Interfaces:
ContinuousMatcher,InlineMatcher,RegexMatcher
- Direct Known Subclasses:
RegexMatcher.ChatStandard
- Enclosing interface:
RegexMatcher
A helper class for regex matchers of the form
[namespace:input].
Most built-in matchers use this.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.samsthenerd.inline.api.matching.ContinuousMatcher
ContinuousMatcher.ContinuousMatchResultNested classes/interfaces inherited from interface com.samsthenerd.inline.api.matching.RegexMatcher
RegexMatcher.ChatStandard, RegexMatcher.Simple, RegexMatcher.Standard -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStandard(String namespace, String innerRegex, net.minecraft.util.Identifier id, Function<String, InlineMatch> matcher, MatcherInfo info) Constructs a simple regex matcher of the form[namespace:(inner)]. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.util.IdentifiergetId()Get the ID for this matchergetInfo()Get info about this matcher.getMatch(MatchResult regexMatch, MatchContext matchContext) Parses an InlineMatch out of the regexMatch.@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()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.samsthenerd.inline.api.matching.ContinuousMatcher
matchMethods inherited from interface com.samsthenerd.inline.api.matching.RegexMatcher
match
-
Field Details
-
IDENTIFIER_REGEX
-
IDENTIFIER_REGEX_INSENSITIVE
-
SEPARATORS_REGEX
-
SEPARATOR_STYLES
-
-
Constructor Details
-
Standard
public Standard(String namespace, String innerRegex, net.minecraft.util.Identifier id, Function<String, InlineMatch> matcher, MatcherInfo info) Constructs a simple regex matcher of the form[namespace:(inner)].- Parameters:
namespace- ideally follow Identifier/ResLoc rules for thisinnerRegex- regex pattern for the inner portion, generally input-likeid- identifier for this matcher. mostly for configmatcher- takes in whatever was matched by the innerRegex and returns an InlineMatch to attach to the entire match.info-
-
-
Method Details
-
getRegex
- Specified by:
getRegexin interfaceRegexMatcher
-
getMatch
Description copied from interface:RegexMatcherParses an InlineMatch out of the regexMatch.- Specified by:
getMatchin interfaceRegexMatcher- 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
-
getMatchAndGroup
@NotNull public @NotNull net.minecraft.util.Pair<InlineMatch,Integer> getMatchAndGroup(MatchResult regexMatch, MatchContext matchContext) Description copied from interface:RegexMatcherParses 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 toRegexMatcher.getMatch(java.util.regex.MatchResult, com.samsthenerd.inline.api.matching.MatchContext)and cover the entire regex match.- Specified by:
getMatchAndGroupin interfaceRegexMatcher- 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.
-
getInfo
Description copied from interface:InlineMatcherGet info about this matcher.- Specified by:
getInfoin interfaceInlineMatcher- Returns:
- matcher's info.
-
getId
public net.minecraft.util.Identifier getId()Description copied from interface:InlineMatcherGet the ID for this matcher- Specified by:
getIdin interfaceInlineMatcher- Returns:
- matcher's ID
-