$string = "ABC (Test1)";
echo preg_replace("/\([^)]+\)/","",$string); // 'ABC '
preg_replace
- процедура замены регулярных выражений на основе Perl. Этот скрипт выполняет сопоставление всех вхождений открывающей скобки, за которым следует любое количество символов , а не закрывающей скобки, и снова после закрывающей скобки, а затем удаляет их:
Распределение регулярных выражений:
/ - opening delimiter (necessary for regular expressions, can be any character that doesn't appear in the regular expression
\( - Match an opening parenthesis
[^)]+ - Match 1 or more character that is not a closing parenthesis
\) - Match a closing parenthesis
/ - Closing delimiter