Why not just use $replace?
echo -a $replace($1-,04 $+ $chr(44) $+ 00,03 $+ $chr(44) $+ 01,4 $+ $chr(44) $+ 00,03 $+ $chr(44) $+ 01)
Note that I have 2 replaces there so it covers 2 of the possible ways to do red on white. I had it replace that with green on black. You can also just use $remove:
echo -a $remove($1-,04 $+ $chr(44) $+ 00,4 $+ $chr(44) $+ 00)
That will just remove the color codes entirely for red on white.
If you don't want to replace/remove it, then change that into an IF:
if (04 $+ $chr(44) $+ 00 isin $1- || 4 $+ $chr(44) $+ 00 isin $1-) {
do this
}
The problem with what you see in all of the above is that it needs extra work to make it handle a single 0 for the background color. You'd have to make any of the three verify that the background doesn't have a # after the single 0 for this to work correctly in those situations. I didn't include that because it was extra work and I don't know if these are what you're really looking for.