I need to create Regular Expression validator which will need to match a text "True" or "False" (Case Insensitive).
I have tried the following regex
^(True|False|TRUE|FALSE)$
Is this correct? but there is problem in Case Sensitive.
Edit
I have tried regex in following answers but it's not firing, because of ?i
With a small optimization:
^(?:tru|fals)e$
Since (?i) is not validating, we'll set the case insensitivity in the code.
For any future reader who needs the code:
Dim FoundMatch As Boolean
Try
FoundMatch = Regex.IsMatch(SubjectString, "^(?:tru|fals)e$", RegexOptions.IgnoreCase)
Catch ex As ArgumentException
'Syntax error in the regular expression
End Try
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With