当前位置:网站首页>How to remove parentheses in PHP regular

How to remove parentheses in PHP regular

2022-06-22 05:08:00 itbigold

  • PHP Remove the curly braces and the contents inside the curly braces

1

2

3

$str= 'dfsas{kslajfljs}45';

$str= preg_replace( '/\{(.*?)\}/', '',$str);

echo$str;

  • PHP Remove parentheses and contents in parentheses

1

2

3

$str= '9(kslajflj)s45';

$str= preg_replace('/\(.*?\)/', '', $str);

echo$str;exit;

  • PHP Remove the angle brackets and the contents inside the angle brackets

1

2

3

$str= '9sfa<kslj>s45';

$str= preg_replace('/\<.*?\>/', '', $str);

echo$str;exit;

  • PHP Remove the brackets and the contents inside the brackets

1

2

3

$str= '9sfa[ksl64546+j]s45';

$str= preg_replace('/\[.*?\]/', '', $str);

echo$str;exit;

原网站

版权声明
本文为[itbigold]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220501182470.html