Regular expressions are "greedy" by default, they match as much as they can.
Adding "?" to a qualifier makes it non-greedy - this seemed to do the job
for me, but I haven't looked too closely at your expression.

str = rereplace(str,
"(\[quote\](.*?)\[/quote\])(?!((?!\[code\]).)*?\[/code\])",
"<blockquote>\2</blockquote>", "ALL")

-----Original Message-----
From: Ewok [mailto:[EMAIL PROTECTED] 
Sent: Monday, 17 January 2005 10:01 a.m.
To: CF-Talk
Subject: RE: regex help (Almost)

The regex works for most cases... but it's not stopping at the next ending
tag...

For example, the quote replac regex...

I have 

[quote]heres a quote[/quote]
Here's some text
[quote]here's another quote[/quote]

The expression replaces quote tags with blockquote tags unless it false
between [code][/code] tags (which it doesntin this case)

The result is 

<blockquote>heres a quote[/quote]
Heres some text
[quote]here's another quote</blockquote>

Which of course should be 
<blockquote>Heres a quote</blockquote>
Heres some text
<blockquote>here's another quote</blockquote>

This is the regex that's causing this...

str = rereplace(str,
"(\[quote\](.*)\[/quote\])(?!((?!\[code\]).)*?\[/code\])",
"<blockquote>\2</blockquote>", "ALL");

How can I change it to stop at the first [/quote] tag?

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.6.12 - Release Date: 1/14/2005
 




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Stay Ahead of Hackers - Download ZoneAlarm Pro
http://www.houseoffusion.com/banners/view.cfm?bannerid=65

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190635
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to