CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Split the email to get the data before the "@"

 



spch2o
New User

Jan 20, 2008, 7:57 PM

Post #1 of 3 (2283 views)
Split the email to get the data before the "@" Can't Post

Hi,

I need to split the recipients in below :-

$recp = '8863322119@istyle.com.tw, 60124602211@maxis.com.my,6581723494@m1.com';

and the result should be a list with only numbers in before the "@". For example :-

@recp = ("8863322119", "60124602211", "6581723494");

Anyone know how to do this with a split function?

Thanks


KevinR
Veteran


Jan 20, 2008, 9:10 PM

Post #2 of 3 (2282 views)
Re: [spch2o] Split the email to get the data before the "@" [In reply to] Can't Post

You don't want to use split for this. You want to use a capturing regexp and the "g" modifier to create a list from the matches found in the string:


Code
$recp = '8863322119@istyle.com.tw, 60124602211@maxis.com.my,6581723494@m1.com';  
@numbers = $recp =~ /(\d+)@/g;
print "$_\n" for @numbers;

-------------------------------------------------


spch2o
New User

Jan 20, 2008, 9:53 PM

Post #3 of 3 (2281 views)
Re: [KevinR] Split the email to get the data before the "@" [In reply to] Can't Post

Yeah. It works. Thank you very much.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives