正则表达式匹配"真"或QUOT;假" [英] Regex to match "True" or "False"
问题描述
我需要建立普通防爆pression验证,这将需要一个文本匹配真或假(不区分大小写)。
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.
修改
我曾尝试在正则表达式如下回答,但它不是因为烧?我
I have tried regex in following answers but it's not firing, because of ?i
推荐答案
我已经检查在这篇文章的所有答案,但毫无效果如预期。
I have checked all the answers in this post but nothing worked as expected.
我猜?我
不Asp.Net RegularEx pression验证支持。
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])$
它工作正常。
这正则表达式将用于动态创建Asp.net RegularEx pressionvalidator
。
This regex will be used for dynamically created Asp.net RegularExpressionvalidator
.
这篇关于正则表达式匹配"真"或QUOT;假"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!