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