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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
(?'openingTag'<) \s*? (?'tagName'\w+) # Once we've got the tagname, match zero # or more attribute sequences (\s*? # Atomic Grouping for efficiency (?> (?!=[\/\?]?>) # Lookahead so that we can fail quickly # match Attribute pieces (?'attribName'\w+) (?:\s* (?'attribSign'=) \s* ) (?'attribValue' (?:\'[^\']*\'|\"[^\"]*\"|[^ >]+) ) ) )* \s*? # Closing Tag can be either > or /> (?'closeTag'[\/\?]?>)
Description
Matches and segments the sections of an opening tag. For more detailed information refer to this blog entry: http://weblogs.asp.net/dneimke/posts/25616.aspx
Matches
<head> | <script language=javascript> | <input type=submit >
Non-Matches
</head>
Author Rating: Not yet rated. Darren Neimke
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: Altered to support PatternWhitespace
Name: Darren Neimke
Date: 3/14/2004 5:21:29 PM
Comment:
Updated this pattern to support PatternWhitespace.


Title: UPDATED EXPRESSION
Name: Darren Neimke
Date: 8/28/2003 3:21:53 AM
Comment:
Altered the 'attribValue' expression to pick up more than just \w's so that it would pick up patterns such as: <LINK href="/regexp.css" type=text/css rel="stylesheet"> ******************************** UPDATED EXPRESSION ******************************** (?'openingTag'<)\s*?(?'tagName'\??\w+)(\s*?(?>(?!=[\/\?]?>)(?'attribName'\w+)(?:\s*(?'attribSign'=)\s*)(?'attribValue'(?:\'[^\']*\'|\"[^\"]*\"|[^ >]+))))*\s*?(?'closeTag'[\/\?]?>)


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