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

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

WBOY
Release: 2016-06-23 14:04:19
Original
897 people have browsed it

     $test = 测试测试(测试123);
Copy after login


替换后为

     $test = 测试测试;
Copy after login



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


回复讨论(解决方案)

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template