RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
href[ ]*=[ ]*('|\")([^\"'])*('|\")
Description
the regex's on this site for pulling links off a page always seemed to be faulty, or at least never worked with PHP, so i made this one. simple, as i'm an amateur with regex's, but stumbled thru it and this one actually works. tested with PHP function: preg_match_all("/href[ ]*=[ ]*('|\")([^\"'])*('|\")/",$string,$matches)
Matches
href="index.php" | href = 'http://www.dailymedication.com' | href = "irc://irc.junk
Non-Matches
href=http://www.dailymedication.com
Author Rating: The rating for this expression. Jason Paschal
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: ur right, again
Name: jason
Date: 10/30/2004 8:28:00 AM
Comment:
as with the previous comment, me, check the Sample Non-matches. why is everyone repeating the Sample Non-matches as if they discovered something new?!


Title: very simple
Name: me
Date: 10/30/2004 8:12:02 AM
Comment:
this won't do <a href=mylink.html target=_top>


Title: ur right, joe
Name: jason
Date: 9/19/2004 1:27:25 PM
Comment:
but i make a note of that in the Sample Non-Matches


Title: Does not work on href's not enclosed in quotes
Name: joe
Date: 9/15/2004 11:02:56 PM
Comment:
If the url is not enclosed in quotes, this regex fails. Such as in this case: href=just/an/example/of/a/nonparsing/url.html


Title: Thank You!
Name: mellomutt
Date: 6/16/2004 9:01:33 PM
Comment:
i had the same trouble, but yours works. your sample code in the description saved me some frustration. thanks again.


Title: regular expression
Name: idioblast
Date: 6/16/2004 8:58:30 PM
Comment:
awsome code!!


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials