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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find IMG tag
Expression
<img[^>]*src=\"?([^\"]*)\"?([^>]*alt=\"?([^\"]*)\"?)?[^>]*>
Description
Use this RegExp to grab SRC($1) and ALT($3) values from IMG tags in valid or invalid HTML (XHTML). SRC param must by before IMG. (thanks to mr. Mrva)
Matches
&lt;img src="xxx"&gt; | &lt;img src=xxx&gt; | &lt;img src="xxx" alt="xxx" /&gt; | &lt;img src="xxx" alt="xxx" width="N" height="N" /&gt; | etc.
Non-Matches
&lt;img&gt; | &lt;img /&gt; | &lt;img alt="XXX" src="XXX"&gt;
Author Rating: The rating for this expression. Martin Švec
Source
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

Title: Update
Name: Anon
Date: 6/1/2007 12:36:28 AM
Comment:
Needed update for a apostophe (I know a rarity): <img[^>]*src=\"?\'?([^\"][^\']*)\'?\"?([^>]*alt=\"?([^\"]*)\"?)?[^>]*>


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