Sadly no. Ben's right, regex isn't very good at this sort of problem, because you can't match the same portion of the string in two different ways. If you could constrain the problem so that there was never more than one newline per quoted string, then you could do it. Without that restriction, however, I believe you're stuck either only replacing the first newline per string, or potentially replacing some outside quotes, because you can't check both ends of the quoted range.
cheers, barneyb On Nov 13, 2007 1:29 PM, Andy Matthews <[EMAIL PROTECTED]> wrote: > Just wait for Barney...he'll have an answer I'll bet. > > -----Original Message----- > From: Ben Doom [mailto:[EMAIL PROTECTED] > Sent: Tuesday, November 13, 2007 1:17 PM > To: CF-Talk > Subject: Re: Regex Gunslingers > > Actually, that's not all that easy. Regex is great for tokenizing, but not > parsing. There are ways to determine whether or not you are "inside" > quotes, but in my experience, looping usually gives you the best results -- > especially when the text is not precicely what you expect. For example, > quotes doubled to escape them, unclosed quotes, etc. > > --Ben Doom > > Josh Nathanson wrote: > > Hey all, > > > > Got a regex challenge...I was able to solve it using an REFind and > > then REReplace, but I'm wondering if anyone can come with a "one-shot" > > way to replace without looping. > > > > I need to remove any carriage returns within a quoted string, but not > > touch them if they are outside quotes. So: > > > > "the quick brown fox \r\n jumps over the \r\n lazy dog" <-- remove the > > \r\n's > > > > My name is mud \r\n <-- leave this one alone > > > > I'm sure this is probably easy for the regex gurus... > > > > -- Josh > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:293252 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

