Hello,
I have the following function:
<cffunctionname="stripHREFs"access="public"returntype="array"output="no"hint="seperate Links from given HTML string, output as a array">
<cfargumentname="html"required="yes">
<cfsetlocal.startpos = 1>
<cfsetlocal.list = ArrayNew(1)>
<cfloopcondition="local.startpos GREATER THAN 0">
<cfsetlocal.linkpos = reFindNoCase('<a\b[^>]*>(.*?)</a>',arguments.html,local.startpos,'true')>
<cfifval(local.linkpos.len[1])>
<cfsetlocal.startpos = local.linkpos.len[1]+local.linkpos.pos[1]>
<cfsetlocal.string = mid(arguments.html,local.linkpos.pos[1],local.linkpos.len[1])>
<cfsetlocal.hrefpos = reFindNoCase('(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+##]*[\w \-\@?^=%&/~\+##])?',local.string,1,'true')>
<cfifval(local.hrefpos.pos[1])>
<cfsetlocal.this.a = mid(local.string,local.hrefpos.pos[1],local.hrefpos.len[1])>
<cfsetlocal.this.title = reReplacenocase(local.string,'<a\b[^>]*.>',"")>
<cfsetlocal.this.title = reReplacenocase(local.this.title,'</a*>',"")>
<cfsetArrayAppend(local.list,local.this)>
<cfsetStructDelete(local,'this')>
</cfif>
<cfelse>
<cfbreak>
</cfif>
</cfloop>
<cfreturnlocal.list>
</cffunction>
It works great, except now my client has decided to include links with an additional attribute called "alias"
The code looks like this, <a href="http://www.acme.com" alias="foo">click me</a>
How can I pull out the "alias" attribute?
TIA