procmail
[Top] [All Lists]

Re: IP regex

2009-02-19 21:46:48
At 21:28 2009-02-19 -0500, Fleet Teachout wrote:
For example (made up) the range of IPs is:

22.33.4.0-22.33.4.255

The last octet is getting me.

I've tried [0-2][0-9][0-9] but in the back of my mind something says "that ain't right!)

One, it'll expect 000 or 001, which isn't how single digit values are represented, and it'll allow up to 299, which is in excess or the maximum value in a valid octet.

The following should work to specify a 0-255 value, allowing for optional leading zeroes on values which might otherwise be represented in single or double digits:

        ([0-1]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))

And is they *any* way to test a regex in actual procmail format? Grep/egrep differ enough that I'm never sure I've got it right.

Sandbox it and throw a known range of values at it.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>