OOOOOOOOO Duh... I think there is...
this URL: http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/regexp.htm is a link to the MM LiveDocs on using RegExs... and there's exclusion parameters, if I remember correctly... Oi... duh! All you need is to use 2 regexes, one that find a [b] and one that checks to see if there's a [code],[/code] around it... We're cleaning out the storage room today because we just moved and have a lot of old crap, so I don't have time to work out any more than that, but if you check that URL for more detail and use a routine that finds a B, checks for CODE before and after, then moves on to the next b, it might work... Laterz, J On Sat, 15 Jan 2005 14:32:21 -0500, Ewok <[EMAIL PROTECTED]> wrote: > 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 > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Purchase Studio MX with Flash Pro from House of Fusion, a Macromedia Authorized Affiliate and support the CF community. http://www.houseoffusion.com/banners/view.cfm?bannerid=51 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190592 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54