开发者

Novice regular expression question

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜