regular expression: replace all text in between {$}
Posted: Tue Apr 29, 2008 9:41 am
Hello all,
A quick one:
I think it should be quite easy but I'm ignorant when it comes to learning regular expressions so here goes.
I'd like to (if it's possible) replace the text in a string like this:
<h2> {$text|title}</h2>
here is some copy
<img src="hello.jpg"/><br/>
{$html|caption}<br/>
with this:
<h2> %title%</h2>
here is some copy
<img src="hello.jpg"/><br/>
%caption%<br/>
so the format is
curly bracket then some text that needs to be erased then a pipe then some text that needs to be kept then a curly bracket.
{text to be erased|text to be kept}.
is that at all possible.
Thanks in advance for your help!
A quick one:
I think it should be quite easy but I'm ignorant when it comes to learning regular expressions so here goes.
I'd like to (if it's possible) replace the text in a string like this:
<h2> {$text|title}</h2>
here is some copy
<img src="hello.jpg"/><br/>
{$html|caption}<br/>
with this:
<h2> %title%</h2>
here is some copy
<img src="hello.jpg"/><br/>
%caption%<br/>
so the format is
curly bracket then some text that needs to be erased then a pipe then some text that needs to be kept then a curly bracket.
{text to be erased|text to be kept}.
is that at all possible.
Thanks in advance for your help!