Thursday, May 15, 2008

Grab User and domain name from email address

How to grab the user id and the domain name from the email address? There are many ways to do this. I'm giving an example of using Perl and regular expression.
my $email = 'ronaldo@fifa.com';
my ($id, $domain) = $email =~ /(.*)\@(.*)/g;
print "$id\n$domain\n";
If anyone knows other ways, welcome to post as a comment.

No comments:

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...