procmail
[Top] [All Lists]

Re: ^TO regexp question

1996-08-11 09:59:35
John Conover asked,

| On page 13 of procmailrc(5), (version 3.1,) the ^TO is substituted
| as:
| 
|     (^(Original ... -To):(.*[^a-zA-Z])?)
| 
| I hate to be so daft, but what does the [^a-zA-Z] do? (A string
| terminated by zero or one instances of punctuation, maybe?)

This really deserves a spot in the FAQ.

You seem to be reading it as ":.*([^a-zA-Z])?", which would mean a colon,
followed by anything or nothing, perhaps ending in a character that isn't
a letter.  It would be just a hard way of writing ":.*[^a-zA-Z]?, and both
of those are just hard ways of writing ":.*", because it boils down to "any
string that starts with a colon."

":(.*[^a-zA-Z])?" is quite different; it means a colon, followed either by
nothing or by a string whose last character isn't a letter of the alphabet. 
So if your recipe has a condition

  ^TOann

Then `ann' has to appear either next to the colon or after a character that
isn't a letter of the alphabet.  So ^TOann will match 

 To:ann
or
 To: ann
or
 To: the old herridan in PR <ann(_at_)wher(_dot_)ev(_dot_)er>

but it won't match

 To: marianne
nor
 To: hannah
nor
 To: danny

because whatever is between the colon and "ann" can't end in a letter of the
alphabet.

Both ^TO and ^TO_ have been modified since then.

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