procmail
[Top] [All Lists]

Re: $MATCH problem

1997-08-11 12:41:00
Francesco Lotti asked,

| I want extract from the body two consecutive matches..
| 
| i.e: subscribe mlist user(_at_)domain
|                ^^^^^ ^^^^^^^^^^^
|               (1=B0)     (2=B0)
| 
| I don't know how to handle it because if I put:
| 
| *^subscribe \/.*
| 
| i get MATCH="mlist user(_at_)domain" while I'd like something like MATCH1=
| mlist and MATCH2=user(_at_)domain(_dot_)
| 
| Is it possible?

It's possible in steps.  Future versions of procmail might make it easier,
but for now, we have to write something like the following.  I don't know
exactly where MATCH1 should end and MATCH2 should begin, so in order to
give some sample code, I'll do it as if MATCH1 should be the first word
(up to a space or a tab) and MATCH2 the rest of the line (except the sepa-
rating space or tab).

      :0 B
      * ^subscribe[     ]+\/[^  ].*
      {
       LINE_TAIL=$MATCH

       :0
       * LINE_TAIL ?? ^^[^      ]+
       { FIRST_PIECE=$MATCH }

       :0
       * $ LINE_TAIL ?? ^^$\FIRST_PIECE[        ]+\/[^  ].*
       { SECOND_PIECE=$MATCH }

       rest_of_code_for_subscribe_messages
      }

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