in reply to Re: Re: Irregular Expression??
in thread Irregular Expression??

Close, but I think this is actually what Red_Dragon is looking for:

$a =~ s/\'/\\\'\\\'/g;

Update: I was a bit too lazy on my copy job, you don't actually have to escape the '. So this will save you some keystrokes:
$a =~ s/'/\\'\\'/g;

-jbWare

Replies are listed 'Best First'.
Re: Re: Re: Re: Irregular Expression??
by benrwebb (Scribe) on Feb 24, 2004 at 17:26 UTC
    Assuming jbware's regex is correct (not testing it), wouldn't it be better to write:

    $a =~ s#'#\'\'#g;

    That way you aren't tracking around a bunch of backslashes? Or am I remembering wrong and s/// doesn't allow it?