Regular Expressions 101

Community Library Entry

-2

Regular Expression
PCRE (PHP <7.3)

/
\((?!([^\(\)\[\]]*(\b)(ARR|ARRANGEMENT|ARRANGEMENTS|ARRANGED|CHOPPED|DUB|EDIT|FT|FEAT|FEATURING|INSTRUMENTAL|MASH UP|MASHUP|MASH-UP|MIX|REMIX|REPRISE|SCREWED|TITLE|VERSION)(\b)[^\(\)\[\]]*)).*?\)
/
g

Description

strip or remove parentheses enclosed text - including the parentheses itself - only if the enclosed text does not contain any of the FULL keyword(s). Leave all parentheses enclosed text if it contains any keyword(s) listed in the regex string. Uses negative lookahead and \b for determining word boundaries. For PostgreSQL, replace \b with \y for word boundaries.

Submitted by marie bacuno - 10 years ago