Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
<\*?font # Match start of Font Tag
(?(?=[^>]+color.*>) #IF/THEN lookahead color in tag
(.*?color\s*?[=|:]\s*?) # IF found THEN move ahead
('+\#*?[\w\s]*'+ # CAPTURE ColorName/Hex
|"+\#*?[\w\s]*"+ # single or double
|\#*\w*\b) # or no quotes
.*?> # & move to end of tag
|.*?> # ELSE move to end of Tag
) # Close the If/Then lookahead
# Use Multiline and IgnoreCase
# Replace the matches from RE with MatchEvaluator below:
# if m.Groups(1).Value<>"" then
# Return "<font color=" & m.Groups(1).Value & ">"
# else
# Return "<font>"
# end if
|
Description |
This RE and MatchEvaluator will remove everything from inside HTML font tags EXCEPT the color declaration. (For ex: allow users to upload HTML content to site without their font tags overridding the font styles set in the CSS, except for the ability to change the font color for special emphasis.)
This works with color declarations using single quotes, double quotes, no quotes, color-names (red, black), Hex colors (#669933), and inline Style declarations inside a font tag. Does not work with inline Style declarations inside other tags like DIV, SPAN, or P (although it could be expanded to include those as well).
|
Matches |
<font size=5 color=black face=Arial> | <font style="font-family:arial;color:red"&
|
Non-Matches |
<DIV style="font-family:arial;color:red"> | <SPAN style="color:red">
|
Author |
Rating:
Not yet rated.
Cheri Verdend
|
Displaying page
of
pages;
Items to