开发者

Matching all substrings inside parentheses but those starting with blacklisted word

开发者 https://www.devze.com 2023-02-20 13:41 出处:网络
In PHP, using preg_replace, how do I write a regular expression so that any phrase, except \"The,\" in pa开发者_如何学JAVArenthesis & preceded by a space is deleted. E.g.,

In PHP, using preg_replace, how do I write a regular expression so that any phrase, except "The," in pa开发者_如何学JAVArenthesis & preceded by a space is deleted. E.g.,

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


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

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

0

精彩评论

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