How to strip all round brackets (parentheses) with and without content from a string in PHP

1 Answer

0 votes
$s = "php (python) java () (php (programming) tutorial) c# (c, c++) javascript()";
 
$s = preg_replace('/\(([^()]*+|(?R))*\)\s*/', '', $s);
 
echo $s;
 
  
/*
run: 
 
php java c# javascript
 
*/

 



answered Nov 4, 2017 by avibootz
edited Nov 5, 2017 by avibootz
...