Splitting @xyz from email id: [email protected]

Hi,

Can someone please explain how to strip username from [email protected]?

Regards,
Sandeep G

On 9/5/07, Sandeep G. [email protected] wrote:

Hi,

Can someone please explain how to strip username from [email protected]?

here’s a quick and dirty regex, might need to be improved

[email protected]’ =~ /(\S*)@/

the resulting ‘user.name’ value will be stored in $1

Adam

Sandeep G. wrote:

Hi,

Can someone please explain how to strip username from [email protected]?

Regards,
Sandeep G

[email protected]”.split("@")[0]
=> “foo”

Butch

That works! thanks for a quick reply! :slight_smile:
Adam C. wrote:

On 9/5/07, Sandeep G. [email protected] wrote:

Hi,

Can someone please explain how to strip username from [email protected]?

here’s a quick and dirty regex, might need to be improved

[email protected]’ =~ /(\S*)@/

the resulting ‘user.name’ value will be stored in $1

Adam

Butch A. wrote:

Sandeep G. wrote:

Hi,

Can someone please explain how to strip username from [email protected]?

Regards,
Sandeep G

[email protected]”.split("@")[0]
=> “foo”

Butch

Thanks Butch, this is clean too!