Hi,
I need your expert help. I'm trying to find a regular expression to replace all text between quotes "{#ANY_TEXT#}"
For example, if I have string like "This is a test {#ANY_TEXT#} string". I need to replace everything starting from {#...#} with another value. For example, If I want to make it blank, then end result should be "This is a test string". There could be several instances of this.
Thanks in advance for your help.
Andrew
Need help finding and replacing text for "{#ANY_TEXT#}"
Moderator: General Moderators
-
andrewlwong
- Forum Newbie
- Posts: 1
- Joined: Tue Sep 15, 2009 9:53 am
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: Need help finding and replacing text for "{#ANY_TEXT#}"
Try this:
Code: Select all
$text = "This is a test {#ANY_TEXT#} string";
echo preg_replace('/{#(?:(?!#}).)*+#}/s', 'REPLACEMENT', $text);