in reply to Using 'ord' in a regular expression for substitution

You don't really need to use a regular expression:

$string =~ tr/\342/'/;

But if you really want to:

$string =~ s/\342/'/g;

Replies are listed 'Best First'.
Re^2: Using 'ord' in a regular expression for substitution
by JavaFan (Canon) on Aug 25, 2010 at 15:29 UTC
    There is a difference. The OP uses /i. If $string has the UTF-8 flag set both â and  will match $r = chr 226; s/$r/'/ig;. And if UTF-8 isn't set, there still may be a locale that plays a role.