Link to home
Start Free TrialLog in
Avatar of rebies
rebies

asked on

Regular Expression Help

I’ve never been good with Regular Expressions.  Can someone help me here?  I have a ton of HTML, and I’m trying to extract all of the link titles from this page.

So a portion of my page looks like…

----
<a href="linkout.cfm?theid=100000">this is the title</a> <a href=" linkout.cfm?theid=100000">title</a> <a href=" linkout.cfm?theid=100000">yet another title</a> outside text <a href="linkout.cfm?theid=100000">last title</a>
----

And I want to get the result of an array, or comma separated titles like:

this is the title
title
yet another title
last title

Any help here?  I am pretty sure this should be fairly easy for someone that understands regular expressions better than I do.

Thanks.

Andrew
Avatar of James Rodgers
James Rodgers
Flag of Canada image

what do you need the listing for?

take a look at this

<script language="JavaScript" type="text/javascript">
function getLinks(){
      linkArray=document.links;
      for(x=0;x<linkArray.length;x++){
            document.getElementById('myDiv').innerHTML+=linkArray[x].innerText+",<br>";
      }
}

</script>

<input type="button" onClick="getLinks()" value="Get Links">
<div id="myDiv"></div>
<CFHTTP URL="http://www.yahoo.com"
       METHOD="get"
    RESOLVEURL="Yes"></CFHTTP>
<cfoutput>
#CFHTTP.FileContent#
</cfoutput>

ASKER CERTIFIED SOLUTION
Avatar of Dain_Anderson
Dain_Anderson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rebies
rebies

ASKER

Dan, that seems to be exactly what I was looking for.  I could not understand how I was to find the match, then get it out of there.  But backreferancing with Match.pos[2] and Match.len[2] does the trick!

Thanks.  Answer accepted.
Avatar of rebies

ASKER

Sorry, meant to say "Dain,"...
No problem -- I've been called worse! :-)

-Dain