in reply to Re: Supress similar chars in the string
in thread Supress similar chars in the string

Newer Perls (>=5.10) also allow you to say

s/(.)\1\1\K\1*//g;

i.e., through the use of \K, you don't need to copy the part of the match you want to keep ($1 in your regex) into the substitution.

Replies are listed 'Best First'.
Re^3: Supress similar chars in the string
by AnomalousMonk (Archbishop) on Jan 18, 2011 at 22:36 UTC
    s/(.)\1\1\K\1*//g;

    Shouldn't  \1* in regex above be  \1+ for reason similar to that discussed in Re^3: Supress similar chars in the string: useless replacement of empty string with empty string? (Or is regex engine smart enough to avoid this null operation?)