need regexp to replace nested tag
Posted on 2005-03-15
hi! I've the follow codes to replace [quote][/quote] tag. but it is not working for nested tags, for example:
[quote]this is a test quote[/quote]
'this doesn't work
[quote]this is a test quote with [quote] nested test code[/quote][/quote]
this 1st open quote takes the 1st close quote which is wrong. the 1st open quote should take the 2nd close quote instead. Any idea how to make this work?
set r = new regexp
r.pattern = "(\[quote((.|\n)*?)\]((.|\n)*?)\[/quote\])"
r.global = true
r.ignorecase = true
newcontent = r.replace(content, "<blockquote> <b>Quote: </b> (originally from $2)<br><br><div class=""quote"">$4</div></blockquote>")
FormatQuote = newcontent