procmail
[Top] [All Lists]

Re: Splitting username(_at_)host(_dot_)

1999-08-12 03:47:27
On Wed, 11 Aug 1999 23:41:38 -0500 (CDT), Christopher Lindsey
<lindsey(_at_)ncsa(_dot_)uiuc(_dot_)edu> wrote:
:0
* RCPT ?? ^^\/.*@
{ USER = $MATCH }
The RCPT variable is set from the arguments and basically I'm trying to
pull out the username... The problem is the fact that it matches
"username@" as opposed to "username".
   * RCPT ?? ^^\/[^(_at_)]+
That should match everything from the start of RCPT to the first
character before an '@'.

(But it doesn't have the side effect to check if there's a @ there in
the first place. If that is desired, you can do something like

    :0
    * RCPT ?? ^^\/.*@
    * MATCH ?? ^^\/[^(_at_)]+
    { USER = $MATCH }

This will still do the wrong thing if there are two @:s but that's
becoming highly theoretical if this is being passed in from incoming
valid e-mail. Perhaps I'd say [^(_at_)]+ instead of .* in the first
condition too, then at least they both match the same thing.

On Thu, 12 Aug 1999 12:54:40 +1000 (EST), Umar Goldeli
<umar(_at_)atlas(_dot_)synflux(_dot_)com(_dot_)au> wrote:
I've tried ^^\/.*?@ to perhaps turn off greedy mode, but that
doesn't help either..

FWIW, .*? is a Perl extension, you shouldn't expect Perl regex tricks
to work in other programs generally.)

/* era */

Oh, for real backrefs

-- 
 Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
  Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition

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