On Thu, Jul 07, 2011 at 03:36:02AM -0500, Stan Hoeppner wrote: > I received a request to ignore IPv4 addresses as well in order to > improve performance. But given the extensive IF loops it seems > we'd only save something like a few picoseconds of CPU time (<30 > expressions processed). If that's actually critical I could add > something like > > /^([0-9]{1,3}\.){3}[0-9]{1,3}$/ DUNNO > > Crude testing with postmap -q shows this matches only a naked > dotted quad, but I'd rather not unleash it without more thorough > testing, or confirmation from resident regex gurus that this will > work as intended. Many rDNS strings contain a dotted quad, so we > want to return DUNNO only for a naked dotted quad.
The anchors at both ends mean you are safe. You start with ^ and end with $, so nothing else can sneak in between those. A simpler expression to accomplish the same thing: /^[0-9\.]$/ DUNNO In English, that says: match a string which contains nothing but numerals and dots. It matches nonsense strings such as "...", but would be safe as per your intent to only match bare IP addresses. -- Offlist mail to this address is discarded unless "/dev/rob0" or "not-spam" is in Subject: header