Hi Ian, I've cc-ed you directy incase the HoF emailing doesn't work again.

> The first ([^]*) clause captures all the
> properties of the anchor tag including the target property.  I want them
> separated.

Hmm, well in theory you'd make the outer bits non-greedy, but when
you've effectively made all parts optional, I'm not sure about
specifying a "priority" for which optional one is most important...
<a([^>]*?)(target="[^"]*")?([^>]*?)>

That aside, your wording suggests you're attempting to get three
separate matches out of that (one for each parenthesis group), but
with rematch function you get an array of matches per expression, but
not an array of groups per match.

If you want that, then you need to grab each anchor, then loop through
and manually convert each one.

Along the lines of this...

<cfset Anchors = rematch( '<a[^>]+>' , Input )/>

<cfdump var="#Anchors#"/>

<hr/>

<cfset Delim = Chr(65536)/>

<cfloop index="i" from="1" to="#ArrayLen(Anchors)#">

        <cfset AnchorParts = rereplace( Anchors[i] ,
'<a([^>]*?)(target\s*=\s*"[^"]+")([^>]*?)>' , '\1#Delim#\2#Delim#\3' )
/>

        <cfdump var="#ListToArray( AnchorParts , Delim )#" 
label="#Anchors[i]#"/>

</cfloop>

<!--- (note the target attr is not optional - because of what the rest
of the code does it's not necessary here) --->


Assuming I'm not misunderstanding you entirely, this still all seems a
bit of an odd request - if you're able to expand more on the overall
problem you're trying to solve (not the regex side, but why are you
doing this, what is the relevance of target here, etc), then it might
be possible to suggest a better overall solution.

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

Archive: http://www.houseoffusion.com/groups/regex/message.cfm/messageid:1214
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