in reply to Re: Regexp: Only tr second occurance
in thread Regexp: Only tr second occurance

I want to delete the second occurance of the string ".0" in a string.
  • Comment on Re: Re: Regexp: Only tr second occurance

Replies are listed 'Best First'.
Re: Regexp: Only tr second occurance
by Abigail-II (Bishop) on Jan 02, 2004 at 12:49 UTC
    There are several ways of doing that. One is:
    {my $i = 0; s/(\.0)/++ $i == 2 ? "" : $1/eg; }

    Abigail