Page 1 of 1

Matching a URL with Regex?

Posted: Mon Jan 22, 2007 8:13 am
by FuzzyLogik
I need to match the following:

<a href="(url)" title="do not need">(description)</a>

I want to pull the URL and description from the URL, and I need it to work whether there is a title tag or not.

Anyone feel like helping me out?

Posted: Mon Jan 22, 2007 8:53 am
by feyd
I would use two patterns. One to pull out the entire link, the second to extract the URL.

Take a look here: viewtopic.php?t=29312

Posted: Fri Feb 02, 2007 11:25 pm
by Ciprian
Hi

Code: Select all

'#<a.*href="([^"]+)"[^>]*(.*)</a>#i'
this works for:

<a href="url1" title="do not need">description1</a>
<a href="url2">description2</a>
<a title="do not need" href="url3">description3</a>

Cheers