![](/img/trans.png)
[英]How can I replace a block of code in a php file using preg_replace and regex expression?
[英]In PHP how can i OR two regex in preg_replace?
我想知道在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);
像这样吗
$plaintext = preg_replace("/(\(.*?\))|(\([^)]+\))/u", "", $plaintext);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.