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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Anchor Href Link URL
Expression
href=(?<QUOTE>[\""\'])?(?<URL>(?<SCHEME>(file|ftp|http|https|news|nntp):\/\/|mailto\:)?(?<EMAIL>[\w-]+@)?(?<HOST>(?(SCHEME)[\w]+(\.[\w-]+)*?))(?<PATH>\/?\w*[\w-%\:\.\+\/]+)?(?<QUERY>\?[\w-%\+:\.]*(=[\w-%\+:\.]*)?(&[\w-%\+\:\.]*(=[\w-%\+:\.]*)?)*)?(?<ANCHOR>\#[\w-%\+:\.]+)?)(?<-QUOTE>[\""\'])?(?#VALIDATE QUOTES/URL)(?(PATH)|(?(SCHEME)|(?!)))(?(QUOTE)(?!))
Description
Matches href links / URLS within html and separates out the Scheme, Email, Domain, Path, Query, Anchor and the full URL. Based on Andrew Lee's version with some further tweaking.
Matches
href="mailto:[email protected]" | href="www.example.com" | href="https://localhost/bla-h3/?x%20#test1" | href='eek' | href="ftp://127.0.0.1/" | href="http://example.com/Search.aspx?k=href&c=-1&m=-1&ps=%20" | href=example.com | href="http://www.example.com/search?q=pi+day&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a#sx"
Non-Matches
href="" | href= | href="javascript: testMe();" | href="bad example"
Author Rating: Not yet rated. Eric Bouwsema
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

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