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 Pattern Title
Expression
<a[a-zA-Z0-9 ="'.:;?]*(name=){1}[a-zA-Z0-9 ="'.:;?]*\s*((/>)|(>[a-zA-Z0-9 ="'<>.:;?]*</a>))
Description
This expression matches only valid html anchors. Those are anchors with an attribute name=. Such anchor can be closed either with </a> or with />. If someone can help - one thing still missing is not matching html tags with parameter href, becazse such should be considered as non valid anchors.
Matches
<a name="anchorName">Anchor</a> | <a name=anchorName />
Non-Matches
<a href="somewhere"> | <a href> | <a name />
Author Rating: The rating for this expression. Aleš Potocnik
Title Test Details Pattern Title
Expression
<a[a-zA-Z0-9 ="'.?_/]*(href\s*=\s*){1}[a-zA-Z0-9 ="'.?_/]*\s*((/>)|(>[a-zA-Z0-9 ="'<>.?_/]*</a>))
Description
An expression that matches all XHTML valid hrefs (links). It even alows spaces like href = "href...", dough this is not quite XHTML valid. It finds only hrefs but not for instance anchors. If you need to find only anchors, replace "href" within expression with "name" and thats it.
Matches
<a href="www.google.com">Google</a> | <a href=www.google.com /> | <a
Non-Matches
<a name="anchor">Anchor</a> | <img src="image.gif">
Author Rating: The rating for this expression. Aleš Potocnik
   Displaying page 1 of 1 pages; Items 1 to 2

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