What do parentheses in a Perl regex do?

Posted by iamrohitbanga on Stack Overflow See other posts from Stack Overflow or by iamrohitbanga
Published on 2010-03-13T05:24:38Z Indexed on 2010/03/17 3:11 UTC
Read the original article Hit count: 270

Filed under:
|

I have been trying several regular expressions in the substitution operator:

$str =~ s/^0+(.)/$1/;

converts 0000 to 0 and 0001 to 1

$str =~ s/^0+./$1/;

converts 0000 to empty string, 000100 to 00, 0001100 to 100.

what difference is the parentheses making?

© Stack Overflow or respective owner

Related posts about perl

Related posts about regex