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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Find Tags and Attributes despite formatting issues
Expression
<\s*[\/]?(?<tag>[a-z:_][-a-z0-9._:]*)(\s+(?<attributes>[a-z:_]*[-a-z0-9._:]*[^\s=><]*)\s*=?\s*("[^"]*"|'[^']*'|"|')*[^\s><]*)*\s*[\/]?>?
Description
Designed to find tags and attributes despite formatting issues, since it may help to find tags like <script a>, since they'll render even though not properly formatted. Also finds closing tags. Designed with the intention of sanitizing html input prior to rendering. However, for some inputs, this can be very slow. I don't recommend doing this with regex
Matches
<h1>, </h1>, <span class=”xyz” style=”font-style:italics;”> <script a> <script abc=> <script abc="...">, <script abc="afgd"abc >, <script abc=""abc def="">
Non-Matches
Plain text, 1 > 0, 5 < 3
Author Rating: Not yet rated. David Hollowell
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

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