mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2007
Posts: 214
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Hello,

I'd like to use a $RegEx expression to return only the name portion before the @1234abcd.com of an email address

test1@emailaddress.com I would only like to get test1

is this possible using a $RegEx?

Last edited by Buggs2008; 30/10/07 05:05 PM.
Joined: May 2007
Posts: 89
T
Babel fish
Offline
Babel fish
T
Joined: May 2007
Posts: 89
Here are 3 possible solutions.

Code:
Alias ChopMail {
  Var %r = $iif($isid,Return,Echo -at)
  If $1 {
    If $regex($1,/^(([^@]+)@[^$]+)$/i) { %r $regml(2) }
  }
}

OR

Alias ChopMail {
  Var %r = $iif($isid,Return,Echo -at)
  If $1 { %r $regsubex($1,/(@[^$]+)$/i,) }
}

OR

Alias ChopMail {
  Var %r = $iif($isid,Return,Echo -at)
  If $1 { %r $gettok($1,1,64) }
}



Usage:

$ChopMail(user@host.domain) returns 'user'.
/ChopMail user@host.domain echoes 'user'.

Regards

Joined: Oct 2007
Posts: 214
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Much thanks, works like a charm.

Thanks again.

Cheers!


Link Copied to Clipboard