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 Unnecessary Spaces in XHTML Attribute
Expression
(?<=(,|;|:))\s(?=((?:(?!<).)*>))
Description
Needing a way to shrink HTML based email to the smallest amount of characters, we wanted to remove any extra unnecessary white space characters in attributes such as style. This finds any space with a proceeding comma, semi-colon, or colon, and then checks with a lookahead for the closing > with a negative lookbehind to make sure that a < opening does not exist. The secondary trailing look behind is done to make sure that it does not change any content contained in the element.
Matches
<table width="750px" cellpadding="0" cellspacing="0" style="font-family: Arial , Helvetica , Sans-Serif ; font-size: 10pt;">
Non-Matches
<td>1, 2, 3</td>
Author Rating: The rating for this expression. Andrew Gruden
   Displaying page 1 of 1 pages; Items 1 to 1

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