Matching all substrings inside parentheses but tho

2020-03-21 09:52发布

问题:

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:

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

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