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 1
Title Test Details 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
   Displaying page 1 of 1 pages; Items 1 to 1

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