perl parentheses in regular expression

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/13 5:35 UTC
Read the original article Hit count: 300

Filed under:
|

I have been trying several regular expressions

$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