Exclusive Or in Regular Expression

后端 未结 13 1743
小鲜肉
小鲜肉 2020-12-05 10:06

Looking for a bit of regex help. I\'d like to design an expression that matches a string with \"foo\" OR \"bar\", but not both \"foo\" AND \"b

13条回答
  •  渐次进展
    2020-12-05 10:31

    You might want to consider the ? conditional test.

    (?(?=regex)then|else)
    

    Regular Expression Conditionals

提交回复
热议问题