我正在尝试使用Regex删除中的( )
和( )
。
例如,字符串: 3 Series (11,879)
替换为: 3 Series
我试过的
preg_replace("/(\w+)/","","3 Series (11,879)");
输出是: (,)
您可以使用:
echo preg_replace('/\h*\([^)]*\)/', "", "3 Series (11,879)");
//=> 3 Series
使用(
和转义)
和匹配它们之间的所有内容[^)]*
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句