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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Anchor Tag, href, title and innerHTML (PHP)
Expression
#<a\s*(?:href=[\'"]([^\'"]+)[\'"])?\s*(?:title=[\'"]([^\'"]+)[\'"])?.*?>((?:(?!</a>).)*)</a>#i
Description
Returns array of full A tag [0], href [1], title [2] and innerHTML [3]. href, title and innerHTML are optional in tag; will return empty if missing. Test will only work using PHP preg_match_all or similar; I ask this site to add that option. Credit goes to user prometheuzz.
Matches
<a id='a' class=''b' href='c' title='d'>innerHTML</a>; <a></a>
Non-Matches
non a tags
Author Rating: The rating for this expression. Jeff Flesher
Source innerHTML
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-2025, RegexAdvice.com | ASP.NET Tutorials