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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find XML Tag
Expression
<(\w+)(\s(\w*=".*?")?)*((/>)|((/*?)>.*?</\1>))
Description
This RE will match XML tag elements. All elements must be closed. Won't match nested tags
Matches
&lt;body&gt; text&lt;br/&gt;More Text &lt;/body&gt; | &lt;a href=&quot;link.html&quot;&gt;Link&lt;/a
Non-Matches
&lt;p&gt; Some Text &lt;p&gt; | &lt;hr&gt; | &lt;html&gt;
Author Rating: The rating for this expression. Michael Ash
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: holy grail
Name: Cameron Knowlton
Date: 9/11/2004 4:44:16 PM
Comment:
wow, this is the holy grail of web page parsing... a blessing on your camels.


Title: Update
Name: Michael Ash
Date: 12/20/2003 10:28:22 PM
Comment:
I changed this regex from <(\w+?).*?(/>|>.*?</\1>) The orginal version would incorrectly match when tags contained a self closing tag. This version should fix that error


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