Class ContextualRegexRule
- Namespace
- BlazOrbit.SyntaxHighlight.Rules
- Assembly
- BlazOrbit.SyntaxHighlight.dll
Matches a regex pattern only when a context predicate is satisfied.
public sealed class ContextualRegexRule : ITokenRule
- Inheritance
-
objectContextualRegexRule
- Implements
Constructors
ContextualRegexRule(TokenType, string, Func<string, int, bool>, bool, int)
Initializes a new instance of the ContextualRegexRule class.
public ContextualRegexRule(TokenType tokenType, string pattern, Func<string, int, bool> contextPredicate, bool requireWordBoundary = false, int priority = 0)
Parameters
tokenTypeTokenTypepatternstringcontextPredicateFunc<string, int, bool>requireWordBoundaryboolpriorityint
Properties
Priority
Gets the priority of this rule. Higher values are evaluated first.
public int Priority { get; }
Property Value
- int
Methods
TryMatch(string, int, TokenizerContext)
Attempts to match a contextual regex pattern at the specified position.
public TokenMatch? TryMatch(string input, int position, TokenizerContext context)
Parameters
inputstringpositionintcontextTokenizerContext