
moroshko
Novice
Jun 1, 2008, 11:58 AM
Post #1 of 1
(300 views)
|
|
A question about groups in regular expressions
|
Can't Post
|
|
Can someone tell me please why in the following program $1 is not defined ? I thought that every group (every pair of parentheses) is going to $1, $2, $3 and so on. Where am I wrong ? Which pairs of parentheses are going to $1, $2, $3, ... ? Thanks in advance !! $_ = "a bc"; if (/(bc)?/) { print "\$1 = [$1]\n" if (defined $1); } else { print "No match !"; };
|