1using System.Collections.Generic;
2using System.Text.RegularExpressions;
61 M = this.
Matches(sl, sr, out
string[] GroupNames);
65 if (!(GroupNames is
null))
67 foreach (
string GroupName
in GroupNames)
69 Group G = M.Groups[GroupName];
72 string Value = G.Value;
86 if (this.partialMatch || (M.Index == 0 && M.Length == sl.Length))
102 lock (this.synchObject)
104 if (this.lastExpression is
null ||
Expression != this.lastExpression)
107 this.regex =
new Regex(
Expression, this.options);
109 List<string> Names =
null;
111 foreach (
string s
in this.regex.GetGroupNames())
113 if (!
int.TryParse(s, out
int _))
116 Names =
new List<string>();
123 this.groupNames =
null;
125 this.groupNames = Names.ToArray();
128 GroupNames = this.groupNames;
130 return this.regex.Match(Value);
134 private Regex regex =
null;
135 private string[] groupNames =
null;
136 private string lastExpression =
null;
137 private RegexOptions options = RegexOptions.Singleline;
138 private bool partialMatch =
false;
139 private readonly
object synchObject =
new object();
149 lock (this.synchObject)
151 this.options = value;
152 this.lastExpression =
null;
162 get => this.partialMatch;
163 set => this.partialMatch = value;
184 Match M = this.
Matches(sl, sr, out
string[] GroupNames);
188 if (!(GroupNames is
null))
190 foreach (
string GroupName
in GroupNames)
192 Group G = M.Groups[GroupName];
195 string Value = G.Value;
203 if (AlreadyFound.TryGetValue(GroupName, out
IElement E) &&
204 !E.AssociatedObjectValue.Equals(ObjValue))
Script runtime exception.
Class managing a script expression.
static IElement Encapsulate(object Value)
Encapsulates an object.
static bool TryParse(string s, out double Value)
Tries to parse a double-precision floating-point value.
ScriptNode right
Right operand.
ScriptNode left
Left operand.
Base class for binary scalar operators.
Represents a constant element value.
IElement Constant
Constant value.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
virtual PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
Expression Expression
Expression of which the node is a part.
int Start
Start position in script expression.
static readonly BooleanValue False
Constant false value.
static readonly BooleanValue True
Constant true value.
RegexOptions Options
Options for regular expression. Default is RegexOptions.Singleline.
ExpressionTransform TransformExpression
Event raised before performing comparison. Can be used to transform expression.
bool PartialMatch
If a partial match is sufficient for operator to return true. (Default=false)
override PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
Match Matches(string Value, string Expression, out string[] GroupNames)
Checks a value against a regular expression.
override IElement EvaluateScalar(IElement Left, IElement Right, Variables Variables)
Evaluates the operator on scalar operands.
Like(ScriptNode Left, ScriptNode Right, int Start, int Length, Expression Expression)
Like
Basic interface for all types of elements.
object AssociatedObjectValue
Associated object value.
PatternMatchResult
Status result of a pattern matching operation.
delegate string ExpressionTransform(string Expression)
Delegate for expression transforms.