Perl Compatible Regular Expressions

Rick Cooper rcooper at
Mon Dec 19 14:52:33 GMT 2011

Paul Welsh wrote:
> Hi all
> Apologies this is off topic.
> I have a quick question about Perl Compatible Regular Expressions.
> I'm using Exim 4.x and a greylist application in conjunction with
> MailScanner obviously.
> The greylist application has a whitelist to cope with senders that,
> when greylisted, try sending again using a different server rather
> than with the same one.
> The whitelist is MTA dependent.  Exim supports Perl Compatible Regular
> Expressions but I'm struggling to match on part of the hostname.  For
> example, this works fine:
> *
> - matches,, etc
> What I want to match, however, is something like:
> mail*
> which would match say,, etc
> I think I need to use the ^ symbol but after much googling can't
> figure it out.  I've tried umpteen permutations to no avail.  Any
> ideas?
> Alternatively, if what I'm seeking to do is very complex, does anyone
> know whether Exim can cope with IP subnets that don't include a whole
> octet?  I've discovered belatedly that the whitelist can cope with,
> for example:
> but not:
> Any assistance gratefully received.

First of all mail* would match on mai+l none or more and that is assuming that you are actually meaning
mail*\.domain\.com (since perl would require the back slash to say match a
dot not any char)

If you are trying to match mail+anything you would want
something like:

^mail.*\.domain\.com which says match mail.(anything)*(none or more
times)+dot+domain+dot+com and start matching on the first char. If matching
numbers is important and nothing will be between the word mail and the
number then

^mail[0-9]+\.domain\.com (match mail+numbers 1 or more times)
But if there is likely to be something between mail and the number then
^mail(.)?[0-9]+\.domain\.com would match or If you need to match just as well then


And then you have to be clear on how reg exes work in exim and the value of,
say \N, in exim's reg ex implementation which is a bit different because of

On the second point of or 26 clearly the /26 will not match on
Ips above 63 and I would have to check and see of exim would consider 63 at
all since in that subnet 63 would be the broadcast address and should not be
assigned a host would would not technically work since the first and last
*usable* Ips would be 1 and 62 (with 0 being network and 63 being broadcast
if 0 is the network). It would be better to ask in the exim list if exim
would consider .63 against a 26 bit mask since it should not occur if the
subnet in question really is 0/26 then 63 would actually match only the 0/24
subnet as a host IP. In other words if my ip is it would not
match but would match


More information about the MailScanner mailing list