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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details 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
   Displaying page 1 of 1 pages; Items 1 to 1

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