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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 2
Title Test Details 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
Title Test Details HTML Anchor
Expression
<a (?:(?<ATTRIBUTES>[\w-]+=[\""\']?[\w\S ]+?[\""\'])[ ]+)*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>[\""\'])?(?:[ ]+(?<ATTRIBUTES>[\w-]+=[\""\']?[\w\S ]+?[\""\']))*>(?<TEXT>.+?)<\/a>(?#VALIDATE QUOTES/URL)(?(PATH)|(?(SCHEME)|(?!)))(?(QUOTE)(?!))
Description
Will match an HTML anchor and will include attributes. It will output various named groups.
Matches
<a target="_blank" class="cssLink" href="http://www.prize-pony.com/pcomp/solarxylophone/">Rory's</a> | <a href="/products/make12xphone/parts/">Bundle Parts</a> | <a href="/products/make12xphone/parts/" target="_blank">Bundle Parts</a> | <a href="mailto:[email protected]">example</a> | <a href="http://www.example.com">example</a> | <a href="https://localhost/bla-h3/?x%20#test1">test</a> | <a href='eek' class='testMe'>eek</a> | <a class="google" href="http://example.com/Search.aspx?k=href&c=-1&m=-1&ps=%20" target="_top">Search</a> | <a href="ftp://127.0.0.1">FTP</a> | <a class="google" href="http
Non-Matches
<a href="">asdas</a> | <a href=">asda2</a> | <a href=>asda3</a> | <a href="javascript: testMe();">testMe</a> | <a href="javascript: testMe();" extraText>testMe</a> | <a href="http://www.example.com" extraText>example</a> | <a href="bad example">bad example</a>
Author Rating: Not yet rated. Eric Bouwsema
   Displaying page 1 of 1 pages; Items 1 to 2

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