in reply to Re: count repeatation
in thread count repeatation

Yes and no. You can still use the tr/// trick by using s///.
my $num = $string =~ s/XX/XX/g;

It works in list context too.

print $string =~ s/XX/XX/g;

Replies are listed 'Best First'.
Re^3: count repeatation
by JavaFan (Canon) on Aug 19, 2009 at 17:48 UTC
    And if XX contains regexp meta characters, only can write:
    s/(XX)/$1/g;
      s/XX//g would work just as fine if you don't mind being destructive.