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?
Matching a URL with Regex?
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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
Take a look here: viewtopic.php?t=29312
Hi
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
Code: Select all
'#<a.*href="([^"]+)"[^>]*(.*)</a>#i'<a href="url1" title="do not need">description1</a>
<a href="url2">description2</a>
<a title="do not need" href="url3">description3</a>
Cheers