On Thu, Nov 11, 2021 at 08:53:01PM +0100, Togan Muftuoglu wrote: > Matus> /(\d+)[.-](\d+)[.-](\d+)[.-](\d+)./ REJECT "generic DNS refused" > > Matus> (trailing . should avoid matching IP Addresses)
That "." would need to be a "[.]" (or "\."), otherwise it'll match the last digit, of a 2 or 3 decimal digit IP octet. But I think that Matus intended to also allow other non-digit charaters, therefore the correct regular expression is: /(\d+)[.-](\d+)[.-](\d+)[.-](\d+)\D/ REJECT "generic DNS refused" Broken: $ postmap -q "172.31.12.175" pcre:<( printf '%s\n/^/ DUNNO\n' '/(\d+)[.-](\d+)[.-](\d+)[.-](\d+)./ REJECT "generic DNS refused"' ) REJECT "generic DNS refused" Working: $ postmap -q "172.31.12.175" pcre:<( printf '%s\n/^/ DUNNO\n' '/(\d+)[.-](\d+)[.-](\d+)[.-](\d+)\D/ REJECT "generic DNS refused"' ) DUNNO I must some day stop being surprised about all the sloppy regular expressions I run into. Regular expressions are programs for a suitable automaton, pay attention to detail! -- Viktor.