in reply to Regular expression substitution question

Sure it can be done ...
$output =~ s/\x7E(?!$)/\x7D\x5E/g;

See perlre where it talks about zero-width lookaheads

Replies are listed 'Best First'.
Re: Re: Regular expression substitution question
by Roy Johnson (Monsignor) on Mar 31, 2004 at 19:01 UTC
    And for us anal-retentive types who hate to replace something with itself:
    s/(?<=\x7E(?!$))/\x5E/g;
    Oh, just shoot me now. I didn't notice 7E->7D. I must not be anal-retentive enough. Thanks, Enlil.
    s/~(?!$)/}^/g;

    The PerlMonk tr/// Advocate
Re: Re: Regular expression substitution question
by rduz (Initiate) on Apr 01, 2004 at 03:08 UTC
    Thanks for the answers. This indeed works quite well.