June 21st, 2013, 11:31 AM
Regex for <A> tag
OK so i'm scraping a page for a links text.
here is the link:
I'm using Rematch to check but can't find a regex expression that will detect this link. The only thing that will remain the same is the <A class="Title" so that is what i need to detect then save the whole link in my array.
Note this doesn't detect the link. I've never been good with Regex expressions so if anybody can lend a helping hand that'd be great.
<cfset arrTitles = REMatch(
June 22nd, 2013, 05:14 PM
June 27th, 2013, 11:45 AM
Thanks for the links, i wasn't sure if regex was the same in JS and CF so i was trying to look specifically for CF regex examples, with little luck.
Originally Posted by kiteless
I think i've got it working now:
This picks up only the link with the test class.
This is some text. It is true that <a class="test" href="http://www.cnn.com">Harry Potter</a> is a good
magician, but the real <a href="http://www.coldfusionjedi.com">question</a> is how he would stand up
against Godzilla. That is what I want to <a href="http://www.adobe.com">see</a> - a Harry Potter vs Godzilla
grudge match. Harry has his wand, Godzilla has his <a href="http://www.cfsilence.com">breath</a>, it would
be <i>so</i> cool.
<cfset matches = reMatch('<[aA]\s.class="test".*?>.*?</[aA]>',s)>
Thanks for pointing me in the right direction Kite.
Last edited by dsfx; June 27th, 2013 at 01:53 PM.
September 6th, 2013, 10:39 AM
As a side note i found an awesome regex tool that's helped me emensley while dealing with this stuff.
It's all live and has most of the regex commands handy on the side bar with an explenation on what they do and how they work.
September 6th, 2013, 03:08 PM