Re: Procmail regex group reuse

Subject: Re: Procmail regex group reuse

Date: Wed, 13 Mar 2013 12:16:29 -0700

To: Guyzmo, Notmuch

Cc:

From: Istvan Marko


Guyzmo <guyzmo+notmuch@m0g.net> writes:

>     Would it be possible to reuse a part of the match regexp in procmail
> so it can be reused in the action part of the rule. 

procmail has a limited way of extracting subexpressions:

       MATCH This variable is assigned to by procmail whenever it is
             told to extract text from a matching regular expression.
             It will contain all text matching the regular expression
             past the `\/' token.

So you get everything between \/ to the end of the whole regexp. In your
case this will get hairy because you need to match stuff after the part
you want to extract. The ?? construct might help to further trim it
down, maybe something like:

* ^TO\/foo\+[a-z]+@mydomain\.tld
* MATCH ?? ^foo\+\/[a-z]+
{
  TAG=$MATCH
}

Or if you are willing to switch to maildrop it has pcre and proper
submatches.

Are you tagging with notmuch-deliver?

-- 
	Istvan

Thread: