in reply to regexp: non-capturing grouping in replacement possible?

Can not a simpler approach give you what you're looking for? capture the 3 which is preceded by 0s, remove those 0s and preserve the 3..
my $str = 'hello kitty 003x009 spanish'; $str =~ s/0*(3)/$1/; print $str;


Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.

Replies are listed 'Best First'.
Re^2: regexp: non-capturing grouping in replacement possible?
by diweooy (Novice) on Nov 26, 2009 at 14:21 UTC
    thanks but it is not about zeros but about learning. I could remove zeroes with a simple 0*.
    $str =~ s/^(hello kitty )0*(\d+)(x\d+.*)$/$1$2$3/;
      learning? this one also removes any leading zero of number after "hello kitty" :-)
      s/(?<=hello kitty )0*(?=\d(?!\d))//
      Update: oops, small mistake, \b replaced with (?!\d)