Displaying page
of
pages;
Items to
Title |
Test
Details
Capture bgcolor attribute for replacing with style attribute
|
Expression |
<.*\b(bgcolor\s*=\s*[\"|\']*(\#\w{6})[\"|\']*).*>
|
Description |
Variable 1 = "complete attribute and value".
Variable 2 = "attribute value only".
For meeting compliance with W3C AA rules, I've been using this in a simple HTML parser to convert certain background tags from the deprecated 'bgcolor' attribute to now using a 'style=background:' and the passed colour. This had to be only on hexadecimal values for my current needs.
Later modifications :
1. Only for certain tags (eg. td,tr,table).
2. If matching an opening apostrophe/quotation mark, only capture variable if there is a closing one.
|
Matches |
table bgcolor="#A3A3A3" | table bgcolor= #A3A3A3" | td bgcolor= #A3A3A3 | td bgcolor=#A3A3A3 alt="somethingelse"
|
Non-Matches |
tr bgcolor="" test | tablebgcolor="#A3A3A3" | table bgcolor="test2" | td bgcolor="red" | td bgcolor="#$%skis"
|
Author |
Rating:
Tom Meier
|
Displaying page
of
pages;
Items to