开发者

Novice regular expression question

开发者 https://www.devze.com 2023-02-17 12:59 出处:网络
I was wonderi开发者_如何学JAVAng, how do I create create a regular expression that allows me to use something akin an \"or\" statement. For example,

I was wonderi开发者_如何学JAVAng, how do I create create a regular expression that allows me to use something akin an "or" statement. For example,

^\w+? [\s?] OR [\\w\\W]*?]$

where the brackets represent the condition.


Like this:

(thing1|thing2)

This will match either "thing1" or "thing2" - see here for more info.

In your example it would be:

^(\w+? [\s?]|[\w\W]*?])$


Use a | between your groups.

0

精彩评论

暂无评论...
验证码 换一张
取 消