Matching all substrings inside parentheses but tho

2020-03-21 09:39发布

In PHP, using preg_replace, how do I write a regular expression so that any phrase, except "The," in parenthesis & preceded by a space is deleted. E.g.,

Concordia University (Anything But The) => Concordia University
American University (The) => American University (The)

1条回答
别忘想泡老子
2楼-- · 2020-03-21 10:23

Does preg_replace support negative lookaheads? If so you can do something like this...

\((?!The\)).*?\)

查看更多
登录 后发表回答