> -----Original Message----- > From: Ewok [mailto:[EMAIL PROTECTED] > Sent: Saturday, January 15, 2005 4:05 AM > To: CF-Talk > Subject: regex help > > 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]
I've done this in my BBML parse here: http://wwww.depressedpress.com/depressedpress/Content/Development/ColdFusion /Extensions/DP_ParseBBML/Index.cfm (It's open source so you can see how its done in there.) The method I used was to first extract all of the [code] blocks. I do what I want with them (in my case color-coding them if selected, changing angle brackets to HTML entities, etc). Then I place those blocks in an array. In the source I replace each block with special string like "<code>***#Cnt#***</code>" where "Cnt" is the position of the block. Then I deal with all the other BBML to be handled. Finally I loop through the source again and replace all the code block placeholders with the converted code blocks from the array. All done. To put it in other words I basically remove the code blocks and handle them separately. But I leave markers where they were so I can put them back after the processing is done. I also do the same thing for [SQL][SQL] blocks. One of the changes I really want to make (someday!) is being able to easily add a "language" attribute the code blocks. So instead of a [code] (which only does basic HTML escaping or color-codes HTML/CF) and [SQL] tag (which only does SQL) you might have "[code language=sql]" or "[code language=html]" or even "[code language=asp]" My problem so far has been trying to find a decent way to define the color-coding process and a decent way to add new languages without having to reissue the tag every time there's a new language. I'm thinking of allowing the tag to take a collection of CFCs as an attribute or coming up with a nested tag structure that allows for this. Ah well... it'll be a while in any case. Jim Davis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190584 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