-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 02/10/12 11:24, John Horne wrote:

> I am trying to do a 'match' of one variable against another:
> 
> ${if match {$h_X-UoP-Loop:} {^$sender_address } }
> 
> The first variable is a space separated list of addresses, but in
> this instance we are checking if the list begins with the sender
> address and then a space.
> 
> However, the sender address may well contain '.', which as a regex
> will match any character. So my question is whether there is any
> function to escape characters such as '.' so that they can then be
> used correctly in a regex?

In perl style regular expressions, \Q disables pattern meta-characters
until \E is reached. So try this:

${if match {$h_X-UoP-Loop:}{^\\Q$sender_address \\E}}

Proof that it works:

mike@ung:~$ exim -be '${if match{foo.bar}{^foo.bar}{true}{false}}'
true
mike@ung:~$ exim -be '${if match{fooXbar}{^foo.bar}{true}{false}}'
true
mike@ung:~$ exim -be '${if match{foo.bar}{^\\Qfoo.bar\\E}{true}{false}}'
true
mike@ung:~$ exim -be '${if match{fooXbar}{^\\Qfoo.bar\\E}{true}{false}}'
false
mike@ung:~$

- -- 
Mike Cardwell  https://grepular.com/     http://cardwellit.com/
OpenPGP Key    35BC AF1D 3AA2 1F84 3DC3  B0CF 70A5 F512 0018 461F
XMPP OTR Key   8924 B06A 7917 AAF3 DBB1  BF1B 295C 3C78 3EF1 46B4
-----BEGIN PGP SIGNATURE-----

iQGGBAEBCgBwBQJQatHuMBSAAAAAACAAB3ByZWZlcnJlZC1lbWFpbC1lbmNvZGlu
Z0BwZ3AuY29tcGdwbWltZTgUgAAAAAAVABpwa2EtYWRkcmVzc0BnbnVwZy5vcmdt
aWtlLmNhcmR3ZWxsQGdyZXB1bGFyLmNvbQAKCRCdJiMBwdHnBK6eCADIp5NvsCrH
qsdT22BwfVzsYk+L5tTqF5nDVNpUmATg5JeNxYbUAP5kRq3L+Oj85oVJMRn1eVCn
r/0uFGjjzHKM67hZ34CApoecp2dZt69k0QWTx7bmiDULOMqMu14AfEMod/Kq6asN
AfzhY3z1DDfs4Q0jyqQfADK9CWW7Kpm+Nck8QCjTARgmDp6H8O3Ia5gtIQEu/v+h
kbIl8+KzwK4rK+Txx+48Ul1hFK91trDa8+uql4Lf03dl5MzzjYU/Ic349qvEt1Qq
9sP54SHisi1/tNvQQhsmgBgV6cuo4llino76INiXCaNa5BqKD6MxuUH1LVEqv+gV
CPpcw9e5f+Wa
=r/i3
-----END PGP SIGNATURE-----

-- 
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

Reply via email to