Regex to match "True" or "False"

asp.net, regex, validation, vb.net

Solution

I have checked all the answers in this post but nothing worked as expected.

I Guess `?i` is not supported in Asp.Net RegularExpression validator.

Finally I used following regex.

^([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])$

It worked as expected.

This regex will be used for dynamically created Asp.net `RegularExpressionvalidator`.

Problem

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`

Original source