I’m using javascript regex to do the following:
I have the html content of a page saved inside a string, and I want to match all URLs on the page.
For example, if the document contains–
<script src = "http://www.a.com">
<a href="http://www.b.com">
<a href= "http://www.c.com">
<a href ="http://www.d.com">
I want the match to be–
http://www.a.com
http://www.b.com
http://www.c.com
http://www.d.com
Any help would be appreciated, thanks!
John Gruber has an excellent regex for URLs over at his site, Daring Fireball: http://daringfireball.net/2010/07/improved_regex_for_matching_urls
You can implement it like so: