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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
# one tag name matcher and three times the style or attribute matcher with each 6 match possibilities (three times to reckon with the attributes placing) # capturing (only one) front space of each attribute # quotes aren't needed to match, but are captures when available < (span|font) # tagname .*? (?: (?: (\s?style="?).*? # style opener ((?:\s?font-size:.+?\s*(?:;|,|(?="))+)|(?:\s?color:.+?\s*(?:;|,|(?="))+))[^"]* # font-size or color style property ((?:\s?font-size:.+?\s*(?:;|,|(?="))+)|(?:\s?color:.+?\s*(?:;|,|(?="))+))[^"]* # font-size or color style property # (the line above should be made optional.) ("?) # style end quote if available | (\s?size="?.*?(?:(?=\s)|"|(?=>))) # size attribute | (\s?color="?.*?(?:(?=\s)|"|(?=>))) # color attribute | (?=>) ) .*? ){3} >
Description
A regex that filters the text property attributes or CSS in a span or font tag, i.e. only the color and font-size style properties and the color and size attributes. But there are two things I want to improve : - First I need the regex to match, even when only one of the two style sheet properties is available (only font-size or only color) - And second, it would be nice if a heading space is captured with the style sheets properties to. I have tried this already but didn't succed. with the tag attributes it does work.
Matches
<span color=blue style="FONT-SIZE: 26pt; color:25;" hello size="4" itworks&gt
Non-Matches
<strong color=blue>bar</strong> | some text
Author Rating: Not yet rated. saul11
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