procmail
[Top] [All Lists]

Re: TO macro

1997-01-03 10:06:01
I guess you were talking about this:

MISCELLANEOUS
     If the regular expression contains `^TO' it will be  substi-
     tuted by `(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope
     |Apparently(-Resent)?)-To):(.*[^a-zA-Z])?)', which should
     catch all destination specifications.


I got that, but what's the UNDERSCORE for??? (^TO_)

The "^TO_" macro is defined in procmail 3.11 but not in 3.10 or earlier
versions.  The "^TO_" macro is intended for email addresses, while "^TO"
is intended for "words", demarcated by non-alphabetics.

    * ^TOfoo

would match the word "foo" anywhere, even *within* an address.

    To: foo
    To: egg-foo-yung
    To: Two Wong Foo <hennahito(_at_)some(_dot_)dom>

while:

    * ^TO_foo

will match "foo" only if it starts an address, or exists as a separate
word: 

    To: foo
    To: foobar
    To: Two Wong Foo <hennahito(_at_)some(_dot_)dom>

but not:

    To: egg-foo-yung

Notice that in both cases a word from the "comment" matched the
condition, possibly intentionally, possibly not.  To ensure that you are
matching a complete address, and not a fragment, you must place a right
context in the pattern.  To avoid matching the "Two Wong Foo", but still
match "foo" as an address, the following condition should work:

    * ^TO_foo[^-a-zA-Z0-9_.]

Here is the snippet from a 3.11 procmailrc man page (I've underlined the
key difference):

       If the regular expression contains `^TO_' it will be  sub-
       stituted by `(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-
       Envelope|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)',
       which should catch all destination specifications
       containing a specific address.
                             ^^^^^^^

       If the regular expression contains `^TO' it will  be  sub-
       stituted by `(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-
       Envelope|Apparently(-Resent)?)-To):(.*[^a-zA-Z])?)', which
       should catch all destination specifications containing a
       specific word.
                ^^^^
___________________________________________________________
Alan Stebbens <aks(_at_)sgi(_dot_)com>      http://reality.sgi.com/aks

<Prev in Thread] Current Thread [Next in Thread>
  • Re: TO macro, Alan K. Stebbens <=