Home  >  Article  >  Backend Development  >  求一个用于字符串替换的正则表达式

求一个用于字符串替换的正则表达式

WBOY
WBOYOriginal
2016-06-23 14:04:19877browse

     $test = 测试测试(测试123);


替换后为

     $test = 测试测试;



把字符串后面括号中的东西全部替换为空。


回复讨论(解决方案)

echo preg_replace('/\([^)]+\)$/','',$test);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn