Matching in perl -
i new perl. trying text in between 2 dots of line, program returns entire line.
for example: have text looks sampledata 1,2 perl .version 1_1.
i used following match statement
$x =~ m/(\.)(.*)(\.)/;
my output $x should version 1_1 getting entire line match.
i appreciate help. thanks.
in code, value of $x not change after match.
when $x matched m/(.)(.*)(.)/, 3 capture groups contain '.', 'version 1_1' , '.' respectively (in order given). $2 give 'version 1_1'.
considering might want part 'version 1_1', need not capture 2 dots. code give same result:
$x =~ m/\.(.*)\./; print $1;
Comments
Post a Comment