在PHP中,如何在preg_replace中使用两个正则表达式?

时间:2014-12-17 13:15:15

标签: php regex

我想知道在PHP中我可以在preg_replace中合并以下两个正则表达式吗?如果是,请解释我如何可能使你。

// I want to make it one line code
$plaintext = preg_replace('/\(.*?\)/u', "", $plaintext);
$plaintext = preg_replace("/\([^)]+\)/u", "", $plaintext);

//Output like 
 $plaintext = preg_replace('/\(.*?\)/u' | "/\([^)]+\)/u", "", $plaintext);

1 个答案:

答案 0 :(得分:1)

这样的东西?

$plaintext = preg_replace("/(\(.*?\))|(\([^)]+\))/u", "", $plaintext);