Home  >  Article  >  Backend Development  >  求php正则.该如何解决

求php正则.该如何解决

WBOY
WBOYOriginal
2016-06-13 12:57:41756browse

求php正则..
例如:$a = "测试(abc)";我想将"(abc)"一并去掉,这个括号可能是"()、()"这两种格式..求正则一条..
------解决方案--------------------
echo preg_replace('/\(.*?\)/','',$a);
------解决方案--------------------
楼上说了一半

$a = strtr($a, array('(' => '(', ')' => ')'));
echo preg_replace('/\(.*?\)/','',$a);

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