Table of Contents

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
object
ContextualRegexRule
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

tokenType TokenType
pattern string
contextPredicate Func<string, int, bool>
requireWordBoundary bool
priority int

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

input string
position int
context TokenizerContext

Returns

TokenMatch?