@@ -853,10 +853,13 @@ public static bool EndsWithInvariant(this string str, string endsWith)
853
853
return str . EndsWith ( endsWith , PclExport . Instance . InvariantComparison ) ;
854
854
}
855
855
856
- private static readonly Regex InvalidVarCharsRegex = new Regex ( @"[^A-Za-z0-9_]" , RegexOptions . Compiled ) ;
857
- private static readonly Regex InvalidVarRefCharsRegex = new Regex ( @"[^A-Za-z0-9._]" , RegexOptions . Compiled ) ;
858
- private static readonly Regex SplitCamelCaseRegex = new Regex ( "([A-Z]|[0-9]+)" , RegexOptions . Compiled ) ;
859
- private static readonly Regex HttpRegex = new Regex ( @"^http://" ,
856
+ private static readonly Regex InvalidVarCharsRegex = new ( @"[^A-Za-z0-9_]" , RegexOptions . Compiled ) ;
857
+ private static readonly Regex ValidVarCharsRegex = new ( @"^[A-Za-z0-9_]+$" , RegexOptions . Compiled ) ;
858
+ private static readonly Regex InvalidVarRefCharsRegex = new ( @"[^A-Za-z0-9._]" , RegexOptions . Compiled ) ;
859
+ private static readonly Regex ValidVarRefCharsRegex = new ( @"^[A-Za-z0-9._]+$" , RegexOptions . Compiled ) ;
860
+
861
+ private static readonly Regex SplitCamelCaseRegex = new ( "([A-Z]|[0-9]+)" , RegexOptions . Compiled ) ;
862
+ private static readonly Regex HttpRegex = new ( @"^http://" ,
860
863
PclExport . Instance . RegexOptions | RegexOptions . CultureInvariant | RegexOptions . IgnoreCase ) ;
861
864
862
865
public static T ToEnum < T > ( this string value )
@@ -951,8 +954,8 @@ public static bool ContainsAny(this string text, string[] testMatches, StringCom
951
954
return false ;
952
955
}
953
956
954
- public static bool IsValidVarName ( this string name ) => InvalidVarCharsRegex . IsMatch ( name ) ;
955
- public static bool IsValidVarRef ( this string name ) => InvalidVarRefCharsRegex . IsMatch ( name ) ;
957
+ public static bool IsValidVarName ( this string name ) => ValidVarCharsRegex . IsMatch ( name ) ;
958
+ public static bool IsValidVarRef ( this string name ) => ValidVarRefCharsRegex . IsMatch ( name ) ;
956
959
957
960
public static string SafeVarName ( this string text ) => ! string . IsNullOrEmpty ( text )
958
961
? InvalidVarCharsRegex . Replace ( text , "_" ) : null ;
0 commit comments