in reply to Variable-width negative lookbehind

$string=~/([^Y]+)X/$1/g;

Replies are listed 'Best First'.
Re: Re: Variable-width negative lookbehind
by Roy Johnson (Monsignor) on May 05, 2004 at 20:24 UTC
    Or, translated into lookbehind notation (and moving the + for more efficiency):
    $string =~ s/(?<=[^Y])X+//g;
    As long as there's a non-Y character preceding, remove any string of Xs.

    The PerlMonk tr/// Advocate