Jump to content

using preg_replace to remove a word and its surrounding brackets


stubarny1

Recommended Posts

		
$variable = "Test string with (brackets)";
$str = preg_replace("/  \(.+/", "", $variable);
echo $str;

 

Hello all,

 

I'm trying to remove the section " (brackets)" from $variable above. I don't understand why the regular expression in my preg_replace operation above didn't work. Please can someone help?

 

Thanks,

 

Stu

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.