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+)(\s*\w*\s*=\s*("[^"]*"|'[^']'|[^>]*))*|/?>
Description
Matches HTML of XML tags, with or without attributes (single-, double-, or non-quoted), closing tags, or self-closing singleton tags.
Matches
<font color="blue"> | </font> | <br />
Non-Matches
this is a test...
Author Rating: Not yet rated. Jean-Philip Losier
Source Derived from Lewis Moten's expression that finds HTML tag properties
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: x
Name: x
Date: 10/27/2008 9:52:13 AM
Comment:
<a href='mailto:jpotrykus@journalsentinel.com'>Jeff Potrykus</a> of the Journal Sentinel


Title: Close but no cigar
Name: Charles
Date: 7/23/2003 7:07:53 PM
Comment:
What about this, which is valid HTML: &lt;a href='test.asp'&gt;link&lt;/a&gt;


Title: "Never-ending" or "eternal" match -- update
Name: Mark
Date: 4/19/2003 7:03:43 PM
Comment:
Oops! I mean to write yours as ("[^"]*"|'[^']*'|[^>]*)* and this (?:"[^"]*"|'[^']*'|[^>])* to replace it. Here, I've added the noncapturing grouping (?: ).


Title: "Never-ending" or "eternal" match
Name: Mark
Date: 4/19/2003 6:57:34 PM
Comment:
You could remove the inner star of the two unlimited quantifiers in the subpattern ("[^"]"|'[^']'|[^>]*)* and avoid the possibility of a never-ending match, ("[^"]"|'[^']'|[^>])*. Alternatively, using "unrolling the loop" technique on this subpattern will protect against possible eternal matches and may also speed-up execution.


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