Thanks Jeff
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Pang Sent: Wednesday, November 21, 2007 4:26 PM To: Sayed, Irfan (Irfan) Cc: beginners @ perl. org Subject: Re: Regular expression to get part of string On Nov 21, 2007 6:47 PM, Sayed, Irfan (Irfan) <[EMAIL PROTECTED]> wrote: > Hi All, > > I have one variable which has the value as follows > > "ccvob01 pts/2 Nov 21 12:17 (135.27.157.38 logged in ....." > > Now I want only "ccvob01" from that string so I wrote reg.exp. as > follows try this: my $usr = "ccvob01 pts/2 Nov 21 12:17 (135.27.157.38 logged in ....."; my ($usr1) = $usr =~ m{(.+?)\s+}; or my $usr1 = (split/\s+/,$usr)[0]; > > my ($usr1)=($usr =~ m{(.+)\S$}); where $usr contains above string. > why do you think this can work? you may take another read at `perldoc perlre` and see what does the \S and $ mean. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/