Steven wrote:
> From what I've been reading so far I think this regex should work:
> [^#]#[a-fA-F0-9]{3,6}
> If I'm correct it would pick up #FF3366 but not ##FF3366.

That will not just pick up #FF3366 it will *also* pick-up the character before 
that (either space, colon, quote, etc).

If you are simply identifying matches, that doesn't make a huge difference - 
however, it also means you need to manually fix matches, which is boring.

I explicitly used a negative lookbehind to exclude any preceeding hash without 
also matching any characters, so that they can be escaped automatically with a 
simple search/replace.


(You only need the "a-f" part if you are doing a case-sensitive match/replace - 
given that this is as simple as ticking/unticking a checkbox in an IDE, I 
didn't bother with that in any of my expressions.)


If you really want to use your CF application for this, you can easily access 
java regex (which supports lookbehinds) by doing:

    NewString = OldString.replaceAll('regex','replacement')

Which probably means you spend much less time manually escaping colours 
everywhere. 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:345644
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to