简体   繁体   中英

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?

Eat : True Sleep : (?:True|False)|Eat : False Sleep : (?!False)True

如上所述,也可以通过负前瞻来实现。

这是必需的正则表达式

Eat.*True.*Sleep.*|Eat.*Sleep.*True

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM