Click to See Complete Forum and Search --> : [RESOLVED] Select all characters before '@' in email


Design-is-BS
05-07-2008, 10:40 AM
My client wants to create temporary usernames from the emails of potential users.

The usernames will simply be the beginning of their email (Charlie_123@gmail.com would be Charlie_123)

How do I select the characters (numbers, letter, and symbols) before the '@'?

I apologize for three posts in a row, but I can't find this anywhere.

Thanks a lot!

MrCoder
05-07-2008, 10:53 AM
$username = preg_replace("/(.*?)@.*/s", "$1", $email_address);

Design-is-BS
05-07-2008, 10:59 AM
Wow, that was easy for you.

Thanks so much MrCoder!

MrCoder
05-08-2008, 03:14 AM
Glad I could help.