Reputation: 1708
Postfix and Regex Experts:
I have a requirement to use Postfix Body Checks to add an empty alt="" parameter to an image link in the body of outgoing emails. (I have no control on the generation of the image link.) Here is an exerpt of the email body:
<img src=3D"http://xxxxxxx.com:81/OT000001MQ=3D=3D.GIF?D=3D2016-03-23" wid=
th=3D"1" height=3D"1"/>
I need Postfix Body Check to add and empty alt parameter alt=3D""
to this link for improving SPAM test score.
I do succeed with this Body Check Regex, but it's an ugly solution:
/height=3D"1"/ REPLACE th=3D"1" height=3D"1" alt=3D""/>
My regex is selecting the entire line of the body text. Could you please suggest a better regex? Thank you.
Upvotes: 1
Views: 2156
Reputation: 42702
"My regex is selecting the entire line of the body text." If you mean you don't want to write the whole line in your replacement text, you can do that using backreferences:
/(.* height=3D"1")(.*)/ REPLACE $1 alt=3D"" $2
You can see this technique used in the first example on the man page, which uses $2
and $4
. This should work with both basic and PCRE regular expressions.
This is not a very precise match though; anything that specifies height="1"
in its HTML will be caught and altered. Matching on the URL of the specific image would be a better choice.
Upvotes: 2