Yes, it's very easy to get carried away with overthinking regex - I've
done it plenty of times. :)


There may be situations where working with only the original text is
required, but I couldn't think of any - once linebreaks are preserved
it should be fine - and I think actually cutting out unwanted parts
way is a simpler method.


However, I have thought up a situation where the regex I supplied would fail...

Consider this:
varY = "ab#LCase("C;DEF;G")#hi";

The nested quotes inside the hashes are valid syntax, but confuse the
regex, and the semicolons would be left when they shouldn't be.

One way of solving that is to first strip all hashed variables - I
think that makes sense, but haven't fully thought it through.

Here's the quick test code I've thrown together for that:

<cfsavecontent variable="reHashed">#([^#]|##)+#</cfsavecontent>
<cfsavecontent variable="reDouble">"([^"]|"")+"</cfsavecontent>
<cfsavecontent variable="reSingle">'([^']|'')+'</cfsavecontent>

<cfoutput>
<pre>
#SourceText#<hr/>
<cfset SourceCopy = jre.replace( SourceCopy , reHashed ,'{hashed}' , 'all' )/>
#SourceCopy#<hr/>
<cfset SourceCopy = jre.replace( SourceCopy , reDouble ,'{dquoted}' , 'all' )/>
#SourceCopy#<hr/>
<cfset SourceCopy = jre.replace( SourceCopy , reSingle  ,'{squoted}' , 'all' )/>
#SourceCopy#<hr/>
</pre>
</cfoutput>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1157
Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.21

Reply via email to