I have to take the first 2 columns out from a line(using regular expression). For that I have written a code like follows,
use strict; use warnings; $lines = 'B6y green $1$Byf3501d$dPtaW2vCbq63sdsw'; $lines =~ s/^(\S+\s\S+)/$1/; print "$lines";
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/;In reply to How regex works here? by nagalenoj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |