1.PHP去除花括号和花括号里面的内容
$str = 'dfsas{kslajfljs}45';
$str = preg_replace( '/\{(.*?)\}/', '',$str);
echo $str;
2.PHP去除括号和括号里面的内容
$str = '9(kslajflj)s45';
$str = preg_replace('/\(.*?\)/', '', $str);
echo $str;exit;
3.PHP去除尖括号和尖括号里面的内容
$str = '9sfa<kslj>s45';
$str = preg_replace('/\<.*?\>/', '', $str);
echo $str;exit;
4.PHP去除中括号和中括号里面的内容
$str = '9sfa[ksl64546+j]s45';
$str = preg_replace('/\[.*?\]/', '', $str);
echo $str;exit;
注意:主要看正则的表达式,根据表达式来灵活改变
来源:CSDN
作者:小白的程序猿
链接:https://blog.csdn.net/Hjingeng/article/details/103764818