At 22:57 2001-01-28 -0800, Eric Hilding wrote:
At 12:02 PM 1/28/01 -0800, Professional Software Engineering wrote:
*
^Received:.*\[(201\.1[0-9][0-9]|202\.0?9[0-9]|211\.0?7[0-9])\.[0-9]+\.[0-9]+\]
This should match IP octets starting with what you're asking for (and
matching the digit counts your example masks represented), while also
handling optional leading zeroes on the octets which are only two digits
long (0? matches zero or one '0').
Tnx so much, Sean, but doesn't it require a "\" at the end?
To escape precisely WHAT?
I think all IP addresses have 4 component parts??? like aaa.bb.cc.dd ...
but the bb could be bbb and the cc could be ccc and the
The above regexp DOES check for four component parts: the first two which
your masks specify (and are a series of OR'd conditions within the grouping
parenthesis, plus two AFTER the parenthesis:
\.[0-9]+\.[0-9]+\]
Read that as:
\.
a dot (vs. a single char wildcard) - starting the third octet
[0-9]+
ONE or more of the digits 0-9 (so yea, it doesn't specify a max of
three - if you want that, in longhand that would be:
[0-9][0-9]?[0-9]?
which would be a single digit optionally followed by one or two more)
\.
a dot again - starting the fourth octet
[0-9]+
just as above
\]
A closing bracket.
In other words, after the aaa.bbb I think I need to put another set of
[0-9] 's in, but in case there is NOT a "0" after the
period in the 2nd position (bbb), I'll be "SOL" ... unless you mean that
0? matches "none" rather than "zero" the number???
Please re-read my original post (in fact, the text you quoted in your reply
- see above), and the procmail manpages. '?' means ZERO or ONE of the
preceeding expression. Thus, 0? is ZERO or ONE (i.e. this optionally
appears). Basically as used, this covers things like: .7x. and .07x. both
of which are valid IP octets
And, don't I need a ")" before the "(" at the front and the ")" at the back???
The parens are for GROUPING the OR'd conditions. If you escaped them,
they'd be interpreted as actual parens, and the OR grouping would go to pot.
So, wouldn't I need something like (except I don't understand the "+" ones
at the end:
* ^Received:.*\[(202\.1[0-9]\.[0-9]\.
The \.[0-9]\. at the end of the line (and elsewhere in your regexp) means a
SINGLE digit for that octet. I very much doubt this is what you want, esp.
in light of the nature of your post for clarification of my regexp.
In other words, after the 202.1, 202.9 and 211.7 ....... each
respectively, to match WHATEVER follows...
regardless of whether the .b.c.d componet portions have 1, 2 or 3 digits
Okay, but as written, your masking showed the second octet to be a SPECIFIC
number of digits (see the original post). However, the .9 and .7 could
only be part of 1 or 2 digit octets anyway, since if they were the leading
digit of the three-digit octet, it would be invalid.
Please consider taking the regexp I provided and throw a bunch of test
messages (perhaps manually generated scenarios so you know that all the
variants are covered) at it? Links to a couple of testbed scripts are
available via the disclaimer page in my .sig.
---
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(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail