I want to know if exist any method in RegEx
class to check if an expression have valid syntax.
I'm not meaning if the regex matches a string or something similar, then the "IsMatch" or "Success" methods does not help me.
To understand me, for example when using the RegEx.Match
method with this expression it throws an exception because the expression have invalid syntax:
"\\\"
(without the double quotes)
I've checked the regex class methods but I can't find any like a "tryparser".
Then to check if an expression have valid syntax I'm doing this:
Try
Regex.Match(String.Empty, "\")
Return True
Catch
Return False
End Try
Just I want to know if I can simplify the code more than that by directly returning a value from a method from regex
class or converting to boolean the result of a regex
class method.
UPDATE:
I create the RegEx in execution time, does not help me external tools.