Exclusive Or in Regular Expression

后端 未结 13 1741
小鲜肉
小鲜肉 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:35

    I know this is a late entry, but just to help others who may be looking:

    (/b(?:(?:(?!foo)bar)|(?:(?!bar)foo))/b)
    

提交回复
热议问题