[英]Conditional regex in.net
I am trying to write a Regex for an expression that matches below inputs 我正在尝试为匹配以下输入的表达式编写正则表达式
Eat : True Sleep : True
Eat : True Sleep : False
Eat : False Sleep : True
but fails 但失败了
Eat : False Sleep : False
How can I put this condition in my Regex expression or is testing this in 2 regex patterns recommended? 如何在我的Regex表达式中放置此条件,或建议在2种regex模式中对此进行测试?
Eat : True Sleep : (?:True|False)|Eat : False Sleep : (?!False)True
如上所述,也可以通过负前瞻来实现。
这是必需的正则表达式
Eat.*True.*Sleep.*|Eat.*Sleep.*True
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.