View Full Version : PCRE and round brackets

07-28-2007, 08:53 PM
was gonna ask how to replace content between round brackets, but I figured it out as I was typing ;). Here it is if'n you are curious:

$string = "there is (34)(pops) nothing here.";
$string = preg_replace('/\(.*?\) ?/', 'la', $string);
$string = "there is lala nothing here.";

I used a variation of this script that twey showed me in an earlier post:

$string = preg_replace('/have.*?not ?/', '', $string); to produce:
$string = preg_replace('/\(.*?\) ?/', 'la', $string);