11/******************************************************************************************************
22 Title : ExpressionEvaluator (https://github.com/codingseb/ExpressionEvaluator)
3- Version : 1.4.14.0
3+ Version : 1.4.14.1
44 (if last digit (the forth) is not a zero, the version is an intermediate version and can be unstable)
55
66 Author : Coding Seb
@@ -28,11 +28,9 @@ public partial class ExpressionEvaluator
2828 {
2929 #region Regex declarations
3030
31- protected const string diactiticsKeywordsRegexPattern = @"\p{L}_" ;
32- protected const string primaryTypesGroupPattern = "(?<primaryType>object|string|bool[?]?|byte[?]?|char[?]?|decimal[?]?|double[?]?|short[?]?|int[?]?|long[?]?|sbyte[?]?|float[?]?|ushort[?]?|uint[?]?|ulong[?]?|void)" ;
33- protected const string primaryTypesRegexPattern = "(?<=^|[^" + diactiticsKeywordsRegexPattern + "])" + primaryTypesGroupPattern + "(?=[^a-zA-Z_]|$)" ;
31+ protected const string primaryTypesRegexPattern = @"(?<=^|[^\p{L}_])(?<primaryType>object|string|bool[?]?|byte[?]?|char[?]?|decimal[?]?|double[?]?|short[?]?|int[?]?|long[?]?|sbyte[?]?|float[?]?|ushort[?]?|uint[?]?|ulong[?]?|void)(?=[^a-zA-Z_]|$)" ;
3432
35- protected static readonly Regex varOrFunctionRegEx = new Regex ( $ @ "^((?<sign>[+-])|(?<prefixOperator>[+][+]|--)|(?<varKeyword>var)\s+|(?<dynamicKeyword>dynamic)\s+|(?<inObject>(?<nullConditional>[?])?\.)?)(?<name>[{ diactiticsKeywordsRegexPattern } ](?>[{ diactiticsKeywordsRegexPattern } 0 -9]*))(?>\s*)((?<assignationOperator>(?<assignmentPrefix>[+\-*/%&|^]|<<|>>)?=(?![=>]))|(?<postfixOperator>([+][+]|--)(?![{ diactiticsKeywordsRegexPattern } 0 -9]))|((?<isgeneric>[<](?>([{ diactiticsKeywordsRegexPattern } ](?>[{ diactiticsKeywordsRegexPattern } 0 -9]*)|(?>\s+)|[,\.])+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?(?<isfunction>[(])?))", RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
33+ protected static readonly Regex varOrFunctionRegEx = new Regex ( @"^((?<sign>[+-])|(?<prefixOperator>[+][+]|--)|(?<varKeyword>var)\s+|(?<dynamicKeyword>dynamic)\s+|(?<inObject>(?<nullConditional>[?])?\.)?)(?<name>[\p{L}_ ](?>[\p{L}_0 -9]*))(?>\s*)((?<assignationOperator>(?<assignmentPrefix>[+\-*/%&|^]|<<|>>)?=(?![=>]))|(?<postfixOperator>([+][+]|--)(?![\p{L}_0 -9]))|((?<isgeneric>[<](?>([\p{L}_ ](?>[\p{L}_0 -9]*)|(?>\s+)|[,\.])+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?(?<isfunction>[(])?))" , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
3634
3735 protected const string numberRegexOrigPattern = @"^(?<sign>[+-])?([0-9][0-9_{1}]*[0-9]|\d)(?<hasdecimal>{0}?([0-9][0-9_]*[0-9]|\d)(e[+-]?([0-9][0-9_]*[0-9]|\d))?)?(?<type>ul|[fdulm])?" ;
3836 protected string numberRegexPattern ;
@@ -41,7 +39,7 @@ public partial class ExpressionEvaluator
4139 protected static readonly Regex stringBeginningRegex = new Regex ( "^(?<interpolated>[$])?(?<escaped>[@])?[\" ]" , RegexOptions . Compiled ) ;
4240 protected static readonly Regex internalCharRegex = new Regex ( @"^['](\\[\\'0abfnrtv]|[^'])[']" , RegexOptions . Compiled ) ;
4341 protected static readonly Regex indexingBeginningRegex = new Regex ( @"^[?]?\[" , RegexOptions . Compiled ) ;
44- protected static readonly Regex assignationOrPostFixOperatorRegex = new Regex ( @"^(?>\s*)((?<assignmentPrefix>[+\-*/%&|^]|<<|>>)?=(?![=>])|(?<postfixOperator>([+][+]|--)(?![" + diactiticsKeywordsRegexPattern + "0 -9])))") ;
42+ protected static readonly Regex assignationOrPostFixOperatorRegex = new Regex ( @"^(?>\s*)((?<assignmentPrefix>[+\-*/%&|^]|<<|>>)?=(?![=>])|(?<postfixOperator>([+][+]|--)(?![\p{L}_0 -9])))" ) ;
4543 protected static readonly Regex genericsDecodeRegex = new Regex ( "(?<name>[^,<>]+)(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?" , RegexOptions . Compiled ) ;
4644 protected static readonly Regex genericsEndOnlyOneTrim = new Regex ( @"(?>\s*)[>](?>\s*)$" , RegexOptions . Compiled ) ;
4745
@@ -51,13 +49,13 @@ public partial class ExpressionEvaluator
5149 protected static readonly Regex endOfStringWithoutDollarWithAt = new Regex ( "^[^\" ]*[\" ]" , RegexOptions . Compiled ) ;
5250 protected static readonly Regex endOfStringInterpolationRegex = new Regex ( "^('\" '|[^}\" ])*[}\" ]" , RegexOptions . Compiled ) ;
5351 protected static readonly Regex stringBeginningForEndBlockRegex = new Regex ( "[$]?[@]?[\" ]$" , RegexOptions . Compiled ) ;
54- protected static readonly Regex lambdaExpressionRegex = new Regex ( $ @ "^(?>\s*)(?<args>((?>\s*)[(](?>\s*)([{ diactiticsKeywordsRegexPattern } ](?>[{ diactiticsKeywordsRegexPattern } 0 -9]*)(?>\s*)([,](?>\s*)[{ diactiticsKeywordsRegexPattern } ][ { diactiticsKeywordsRegexPattern } 0 -9]*(?>\s*))*)?[)])|[{ diactiticsKeywordsRegexPattern } ](?>[{ diactiticsKeywordsRegexPattern } 0 -9]*))(?>\s*)=>(?<expression>.*)$", RegexOptions . Singleline | RegexOptions . Compiled ) ;
55- protected static readonly Regex lambdaArgRegex = new Regex ( $ "[ { diactiticsKeywordsRegexPattern } ](?>[{ diactiticsKeywordsRegexPattern } 0 -9]*)", RegexOptions . Compiled ) ;
52+ protected static readonly Regex lambdaExpressionRegex = new Regex ( @"^(?>\s*)(?<args>((?>\s*)[(](?>\s*)([\p{L}_ ](?>[\p{L}_0 -9]*)(?>\s*)([,](?>\s*)[\p{L}_][\p{L}_0 -9]*(?>\s*))*)?[)])|[\p{L}_ ](?>[\p{L}_0 -9]*))(?>\s*)=>(?<expression>.*)$" , RegexOptions . Singleline | RegexOptions . Compiled ) ;
53+ protected static readonly Regex lambdaArgRegex = new Regex ( @"[\p{L}_ ](?>[\p{L}_0 -9]*)", RegexOptions . Compiled ) ;
5654 protected static readonly Regex initInNewBeginningRegex = new Regex ( @"^(?>\s*){" , RegexOptions . Compiled ) ;
5755
5856 // Depending on OptionInlineNamespacesEvaluationActive. Initialized in constructor
59- protected string InstanceCreationWithNewKeywordRegexPattern { get { return $ @ "^new(?>\s*)((?<isAnonymous>[{{])|((?<name>[{ diactiticsKeywordsRegexPattern } ][ { diactiticsKeywordsRegexPattern } 0-9 { ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) } ]*)(?>\s*)(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?(?>\s*)((?<isfunction>[(])|(?<isArray>\[)|(?<isInit>[{{]))?))"; } }
60- protected string CastRegexPattern { get { return $ @ "^\((?>\s*)(?<typeName>[{ diactiticsKeywordsRegexPattern } ][ { diactiticsKeywordsRegexPattern } 0-9 { ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) } \[\]<>]*[?]?)(?>\s*)\)"; } }
57+ protected string InstanceCreationWithNewKeywordRegexPattern { get { return @"^new(?>\s*)((?<isAnonymous>[{{])|((?<name>[\p{L}_][\p{L}_0-9" + ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) + @" ]*)(?>\s*)(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?(?>\s*)((?<isfunction>[(])|(?<isArray>\[)|(?<isInit>[{{]))?))"; } }
58+ protected string CastRegexPattern { get { return @"^\((?>\s*)(?<typeName>[\p{L}_][\p{L}_0-9" + ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) + @" \[\]<>]*[?]?)(?>\s*)\)"; } }
6159
6260 // To remove comments in scripts based on https://stackoverflow.com/questions/3524317/regex-to-strip-line-comments-from-c-sharp/3524689#3524689
6361 protected const string blockComments = @"/\*(.*?)\*/" ;
@@ -69,8 +67,8 @@ public partial class ExpressionEvaluator
6967
7068 // For script only
7169 protected static readonly Regex blockKeywordsBeginningRegex = new Regex ( @"^(?>\s*)(?<keyword>while|for|foreach|if|else(?>\s*)if|catch)(?>\s*)[(]" , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
72- protected static readonly Regex foreachParenthisEvaluationRegex = new Regex ( @"^(?>\s*)(?<variableName>[" + diactiticsKeywordsRegexPattern + " ](?>[" + diactiticsKeywordsRegexPattern + @"0 -9]*))(?>\s*)(?<in>in)(?>\s*)(?<collection>.*)", RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
73- protected static readonly Regex blockKeywordsWithoutParenthesesBeginningRegex = new Regex ( @"^(?>\s*)(?<keyword>else|do|try|finally)(?![" + diactiticsKeywordsRegexPattern + "0 -9])", RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
70+ protected static readonly Regex foreachParenthisEvaluationRegex = new Regex ( @"^(?>\s*)(?<variableName>[\p{L}_ ](?>[\p{L}_0 -9]*))(?>\s*)(?<in>in)(?>\s*)(?<collection>.*)" , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
71+ protected static readonly Regex blockKeywordsWithoutParenthesesBeginningRegex = new Regex ( @"^(?>\s*)(?<keyword>else|do|try|finally)(?![\p{L}_0 -9])" , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
7472 protected static readonly Regex blockBeginningRegex = new Regex ( @"^(?>\s*)[{]" , RegexOptions . Compiled ) ;
7573 protected static readonly Regex returnKeywordRegex = new Regex ( @"^return((?>\s*)|\()" , RegexOptions . IgnoreCase | RegexOptions . Singleline | RegexOptions . Compiled ) ;
7674 protected static readonly Regex nextIsEndOfExpressionRegex = new Regex ( @"^(?>\s*)[;]" , RegexOptions . Compiled ) ;
0 commit comments