SPUG: [OT] procmail extended regexp Re: Regular Expression

John W. Krahn krahnj at telus.net
Sun Jul 10 15:08:08 PDT 2005

Yitzchak Scott-Thoennes wrote:
> On Thu, Jul 07, 2005 at 03:05:10PM -0700, John W. Krahn wrote:
>>John Costello wrote:
>>>On Thu, 7 Jul 2005, Duane Blanchard wrote:
>>>>My favorite online reference is http://www.regular-expressions.info/
>>>>which covers more material for more environments than I can fathom.
>>>Related to regular expressions, does anyone know of a good discussion of 
>>>procmail's regular expressions?  I encountered an odd example (discussed 
>>>earlier this month on LondonPM) in which I wasn't sure if procmail would 
>>>treat $? as an environment variable or an optional end-of-line character.
>>You can't use quantifiers with zero-width assertions because they match at a 
>>position in the string not any characters.  If you want an optional 
>>end-of-line you have to do something like "($|)" (match end-of-line or nothing.)
> I know you are responding to a question about procmail regular
> expressions, but I want to clarify that perl does allow ? or other
> quantifiers after zero-width assertions (though I think $? will always
> be treated as a variable interpolation, so you'd have to say (?:$)? ).

Wow.  I was surprised to find out that it indeed does work, at least in Perl,
for example \Z?, \z?, \A?, \b?, etc.  You learn something new every day.  :-)

use Perl;

More information about the spug-list mailing list