stubarny1 Posted July 4, 2011 Share Posted July 4, 2011 $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 Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted July 4, 2011 Share Posted July 4, 2011 <?php $variable = "Test string with (brackets)"; $str = preg_replace('~\(.*?\)~', '', $variable); echo $str; ?> Quote Link to comment Share on other sites More sharing options...
stubarny1 Posted July 5, 2011 Author Share Posted July 5, 2011 Thanks QuickOldCar Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.