Sorry... it is [code][/code] eventually those tags are turned into <pre></pre>
I was hoping there was some magical regex way of saying except when it starts with blah and ends with blah All of the processing behind doing it this way (which is closer to what I started to do) wouldn't really be worth it I don’t think. But a mix of this and Jim's may work out :) All instances of [code]*[/code] should be easy to find and store in vars Replace them with a placeholder [**CODEBLOCK1**], [**CODEBLOCK2**] etc... Convert all my tags Then replace the placeholders with the original block of code. Thanks for the brain jump start. -----Original Message----- From: Jared Rypka-Hauer - CMG, LLC [mailto:[EMAIL PROTECTED] Sent: Saturday, January 15, 2005 1:33 PM To: CF-Talk Subject: Re: regex help Hmmmm... lets see... You'd want to use a few UDFs, and a struct or two... first UDF would be findAllCodeTags, and would call findCodeTag, which would find a code tag and return the pos, and len, arrays, which findAllCodeTags would store in an array. Then, you'd want a findAllBTags and findBTag, which would do the same thing for the <b> tags. and store them in an array. Then, you'll want to grab the first start, pos, combo from B's array and verify that it doesn't fall between the values of pos and pos+len for any element in the Code struct, and if it does, delete the element from the b array. Your findAllCodeTags and findAllBTags would probably have a structure of something like this (note that item 2 is a guess at the regex, not known to be right!): 1) code = arrayNew(1) 1.5) iteration = 1 2) location = first instance of [\[code\]]*[\[\/code\]] (location = struct with start, pos elements)(note: I'm confused, is it [code] or [pre]?) 3) store reFind result with arrayAppend(code, location) 3.5) increment iteration (interation = iteration+1) 4) run reFind again, using code[iteration-1] to get pos+len from the previous run for the starting location of your new search 5) do this till you run out of text Same thing for B, just change the names... As for comparing the 2, get the location of the first B (looping from 1 to arrayLen will get the whole thing, I'm just thinking thru the logic here...) loop from 1 to arrayLen(b) index=i SUBLOOP: from 1 to arrayLen(code) index=j if b[i] NOT between code[j].pos, code[j].pos[1]+code[j].len[1] remove b[i] exit nested loop increment i If you get it working, you'll end up with a b array that has the starting and ending positions for all the [b] tags in your text that are safe to replace, based on your regular expression you used to find them. Granted, what I've typed in here is messy, and there's probably many kinks to work out. It's just the basic structure of the first thing that ran thru my mind when I read your problem: 2 arrays, about 5 UDFs, and the BETWEEN operator... it should work fine. Let us know how you come out! Laterz, J -- Continuum Media Group LLC Burnsville, MN 55337 http://www.web-relevant.com http://cfobjective.blogspot.com On Sat, 15 Jan 2005 04:04:56 -0500, Ewok <[EMAIL PROTECTED]> wrote: > This is a tough one... > > It's an old bbml parser I wrote a while back and im trying to modify it a > little. > > I want to search through the string and replace all instances of [b] with > <b> UNLESS it falls between [pre] and [/pre] > > I just can't seem to get it right. > > Replace [b] with <b> except when it starts with [code]* and ends with > *[/code] > > Even that sentence was hard to write at 4 in the morning ZZzzzz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190589 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