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 |
|
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'[\/\?]?>)