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 HTML Anchor tag
Expression
<a\s+(?:(?:\w+\s*=\s*)(?:\w+|"[^"]*"|'[^']*'))*?\s*href\s*=\s*(?<url>\w+|"[^"]*"|'[^']*')(?:(?:\s+\w+\s*=\s*)(?:\w+|"[^"]*"|'[^']*'))*?>[^<]+</a>
Description
This will match an entire HTML tag and will capture the href portion into the named capture "url". It will match any anchor tag with any number of attributes.
Matches
The entire &lt;a href=""&gt;&lt;/a&gt; tag
Non-Matches
Links that include any html within the tag.
Author Rating: The rating for this expression. Derek Pinkerton
Title Test Details HTML Anchor (link) tag
Expression
<a\s+(?:(?:\w+\s*=\s*)(?:\w+|"[^"]*"|'[^']*'))*?\s*href\s*=\s*(?<url>\w+|"[^"]*"|'[^']*')(?:(?:\s+\w+\s*=\s*)(?:\w+|"[^"]*"|'[^']*'))*?>.+?</a>
Description
This regex will match all html link tags and captures the url into a named capture "url". There can be any html code between the opening and closing link tags. You must use this with the multiline and ignore case options selected.
Matches
Any html link (anchor) tag with any content between the opening and closing link tags
Non-Matches
all other html tags, link tags without an href section.
Author Rating: Not yet rated. Derek Pinkerton
   Displaying page 1 of 1 pages; Items 1 to 2

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