On Thu, Mar 20, 2003 at 01:18:17PM -0800, Tom Most wrote:
I am trying to filter email addresses which are sent to a domain in
the format of 1-20 lower case or numeric characters, a dot, one or
two numeric characters, then ending with @domain.tld. The regular
expressions with which I am familiar would dictate that the filter
would look like:
* ^TO_[a-z0-9-]{1,20}+(\.[0-9-]{1,2}+)@domain\.tld
However, this does not seem to work. Any ideas of the source of the
problem?
Sure: the regexes with which you are familiar are not how procmail
works, is the source of your problem. `man procmailrc' says,
[. . .] regular
expressions are completely compatible to [sic] the normal
egrep(1) extended regular expressions.
Not the gnu/POSIX ones.
Note, also, that procmail is not case-sensitive unless you explicitly
tell it to be so (with the D flag).
You have several options to code what you want in procmail. One
would be to have procmail count the chars. This would require scoring
syntax, for which, see `man procmailsc'. Another is to express twenty
of your chars. Yet another is to capture what's there, then run it
up against a long-enough string that you know is good.
Are you sure you want to use ^TO_? That is usually reserved for
cases when you can't predict where the address will appear. If
you are expecting these messages and they are to conform to a
specific format, then you should code for what you are expecting,
e.g., the To: header specifically.
This should work:
:0 D # inside brackets is a space and a tab
* ^To:[
]*<?\/[a-z0-9]+\(_dot_)[0-9][0-9](_at_)domain\(_dot_)tld\>
* 21^0 MATCH ?? ^^\/[a-z0-9]+
* -1^1 MATCH ?? [a-z0-9]
{ do_something }
Note that the `\>' at the end is a special procmail macro token,
not a quoted close-angle (though that char is part of the class
that `\>' would contain). See `man procmailrc'.
--
dman
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail