Title |
Test
Find
Pattern Title
|
Expression |
<[a-zA-Z]+(\s+[a-zA-Z]+\s*=\s*("([^"]*)"|'([^']*)'))*\s*/> |
Description |
Matches a valid "empty" tag (has trailing slash). Note, if you run it against a string such as <img src="test.gif" alt="<hr />"> it will indeed return a match. But, the match is not at character 1 like you'd suspect, but rather it's matching the internal <hr />. If you look at the source of this tag (http://concepts.waetech.com/unclosed_tags/) you'll find a whoe suite of regex's for matching html tags. Using them you could feasibly step though a document and avoid this mismatch as the outer tag would match *in totality* and you'd completely skip this inner match.
|
Matches |
<img src="test.gif"/> |
Non-Matches |
<img src="test.gif"> | <img src="test.gif"a/> |
Author |
Rating:
Not yet rated.
Joshua Olson
|
Source |
http://concepts.waetech.com/unclosed_tags/ |
Your Rating |
|
Title: Non-Greedy?
Name: awc
Date: 12/5/2008 3:56:00 PM
Comment:
After the [^"]* and [^']*, shouldn't there be a ? to make it non-greedy? Without the question mark, it'll eat up an entire page of HTML! Correct me if I'm wrong...
Title: No parse error for me
Name: Darren Neimke
Date: 4/29/2004 3:27:56 AM
Comment:
I just copied and pasted this expression into The Regulator and it parsed just fine. You can also click "test" to go and test it for yourself on this site's Testing tool.
Title: parse error
Name: parse error
Date: 4/28/2004 6:48:41 AM
Comment:
this expr gives parse error!!!!!!!!!!!!