Vis*_*hnu 6 php regex string replace preg-replace
嗨,我想删除大括号内的所有内容,例如,如果字符串是helloz,我希望输出只是helloz
我使用下面的代码,但必须有一些简单的方法来做.有人请告诉我how.thanks
[hi] helloz [hello] (hi) {jhihi}
Run Code Online (Sandbox Code Playgroud)
Dam*_*eem 17
这应该工作:
$name = "[hi] helloz [hello] (hi) {jhihi}";
echo preg_replace('/[\[{\(].*[\]}\)]/U' , '', $name);
Run Code Online (Sandbox Code Playgroud)
将它粘贴到某处,如:http://writecodeonline.com/php/,看它是否有效.