Hi here is a regex that should do the job. It does a little more that you are
asking for. I felt like playing around with the regex.
<cfsavecontent
variable="regex">(<a[^>]*href=['"](([^'"]*)?([^"']ProductID=?([^&"']*)[^'"]*))['"]>([^<]*)<\/a>)</cfsavecontent>
<cfsavecontent variable="text">
<a style="mystyle:as;" href="index.cfm?x=1&ProductID=5&y=2">I am link 1</a><br
/>
<a href="index.cfm?x=1&z=5&y=2">I am link 2</a><br />
<a href="index.cfm?ProductID=1&z=5&y=2">I am link 3</a><br />
<a href="index.cfm?x=1&z=5&ProductID=2">I am link 4</a><br />
<a href="index.cfm?x=1&ProductID&y=2">I am link 5</a><br />
</cfsavecontent>
<fieldset>
<legend>Text</legend>
<cfoutput>#text#</cfoutput>
</fieldset>
<cfset result = ReFindNoCase(regex,text,1,true) />
<cfset resultArray = ArrayNew(1) />
<cfloop condition="#result["len"][1]# neq 0">
<cfset info = StructNew() />
<cfset info.match = Mid(text,result["pos"][2], result["len"][2]) />
<cfset info.href= Mid(text,result["pos"][3], result["len"][3]) />
<cfset info.hrefbeforeProductID= Mid(text,result["pos"][4],
result["len"][4]) />
<cfset info.hreffromProductIDPlus = Mid(text,result["pos"][5],
result["len"][5]) />
<cfset info.ProductID = Mid(text,result["pos"][6], result["len"][6]) />
<cfset info.LinkText = Mid(text,result["pos"][7], result["len"][7]) />
<cfset ArrayAppend(resultArray, info) />
<cfset text = removeChars(text,result["pos"][1], result["len"][1]) />
<cfset result = ReFindNoCase(regex,text,1,true) />
</cfloop>
<cfdump var="#resultArray#">
Thanks,
Jason Morgan.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:299100
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4