RegEx pattern for anchor tags

Scott Cate just wrote a blog on his first (from scratch) RegEx pattern to find anchor <a> tag.  Here is my revision:

<a[\s]?href=["'](?<url>[^"]+[.\s]*)["']>(?<name>[^<]+[.\s]*)</a>

I simply added support for the href value to be enclosed in either single or double quotes.

Published Friday, June 18, 2004 2:51 PM by Palermo4
Filed under: ,

Comments

# re: RegEx pattern for anchor tags

Friday, June 18, 2004 10:13 PM by Jerry Pisk
You don't care about anchors with other attributes, such as id, class, style, event handlers and so on?

# re: RegEx pattern for anchor tags

Friday, June 18, 2004 11:52 PM by J. Michael Palermo IV
Good point! Thanks for the comment. Although I don't care about extracting such information, your comment made me realize that the pattern did not match anything that included such. Therefore, I am posting a new blog to remedy the situation.

Leave a Comment

(required) 
(required) 
(optional)
(required)