Re: reg. expressions
| From: | Afan Pasalic | Date: | Wed, 13 Oct 2004 16:50:01 +0000 |
| Subject: | Re: reg. expressions | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199395@lists.php.net to get a copy of this message | ||
In my case it will be actually "product name (product number)" and always the same. That means Matt's code will do exactly what I need.
But, thanks for your post - could happen to use that on other place
:)
Thanks John
-afan
John Holmes wrote:
Matt M. wrote:Just note that if there are two "bracketed" patterns in a string, this will have issues. It may or may not be an issue for you, though, depending up on your data. As an alternative: $string = "something (something_2) something (something_4)"; $pattern = '/\([^)]\)/'; //or $pattern = '/\(.*\)/U'; $replacement = ''; echo preg_replace($pattern, $replacement, $string); Also, if there could be line breaks within the "bracketed" text, you'll need extra modifiers... it all just depends upon your data.on one place I have string "something (something_2)" I have to take out of the string everything in brackets and brackets as well. probably I will need to use Regular Expression Functions but I'm really bad with them :)$string = "something (something_2)"; $pattern = "/\(.*\)/"; $replacement = ""; echo preg_replace($pattern, $replacement, $string);