laziness, impatience, and hubris | |
PerlMonks |
How regex works here?by nagalenoj (Friar) |
on Apr 08, 2009 at 04:54 UTC ( [id://756228]=perlquestion: print w/replies, xml ) | Need Help?? |
nagalenoj has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks,
I have to take the first 2 columns out from a line(using regular expression). For that I have written a code like follows,
But, its matching the whole line. why? When I have changed the regex as follows, its working fine. How both differs. Why the first one doesn't work? $lines =~ s/^(\S+\s\S+).*/$1/;
Back to
Seekers of Perl Wisdom
|
|