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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
(?:[\w]*) *= *"(?:(?:(?:(?:(?:\\\W)*\\\W)*[^"]*)\\\W)*[^"]*")
Description
This Pattern matches HTML attributes with quoted quotes or other non-word characters correctly. I used it in an parser-engine. Replace the quotes in this RX to match other boundaries.
Matches
<HTMLTAG onClick="jsfunc(\"foo\")">
Non-Matches
<HTMLTAG onClick sometext>
Author Rating: The rating for this expression. Lars Echterhoff
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: Slight extension
Name: Matthew D Erwin
Date: 5/1/2008 2:42:53 PM
Comment:
An extension onto this to handle attribute cases with or without quotes (could be made more robust on the \w and I'm sure compressed a bit): [\s\t]+\w[\s\t]*=[\s\t]*((\"((?:(?:(?:(?:(?:\\\W)*\\\W)*[^"]*)\\\W)*)[^\">]*))|((?:(?:(?:(?:(?:\\\W)*\\\W)*[^"]*)\\\W)*)[^\"\s\t/>]*)) Works well for extracting even poorly formed attributes inluding cases like: <img src="some value/> <img src=something/> <img src="someting \"with escaped items\"\s"/> Hope this is helpful to someone.


Title: ty
Name: Moe
Date: 11/6/2006 6:12:23 AM
Comment:
Works great, ty.


Title: Thanks - you saved my sanity
Name: Greg
Date: 6/29/2006 6:05:06 PM
Comment:
Thanks for posting this. You saved me hours of confusion. Good job.


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