procmail
[Top] [All Lists]

Re: \/ is not the same as ()\/

1997-11-18 11:57:17
Era Eriksson read Philip Guenther's explanation and asked,

| Then why does this also grab only two lines?
| 
| :0B
| * ()\/$.*$.*$
| { LOG=" d |$MATCH| d " }
| 
| And/or why isn't this leading newline logged?

Philip has already answered the question, but I'd like to supply an answer
from a different perspective:

The initial "$" is matched to a putative newline, not to a real one that is
actually in the text.  Putative newlines are never included in $MATCH.

Comparably, in more recent versions of procmail that do not drop a closing
newline from $MATCH,

  * HOST ?? ^^\/.+$

will set $MATCH to a value that ends with the last character of $HOST, not
with an appended newline, because the $ matched a putative newline, not a
real one.

That's why the above recipe doesn't result in a value for $MATCH that starts
with a newline; that first $ is matched to a putative newline, which procmail
never puts into $MATCH.