silentq has asked for the wisdom of the Perl Monks concerning the following question:
Hi. I'm dealing with a problem where hexadecimal character references such as '\x{FEFF}' and 'chr(0xFEFF)' are ignored when they appear inside a regex expression.
However, I can copy hexidecimal or decimal references into a Perl variable, insert that variable into a regex, and then it works. Here's an example:
$string = 'ABC'; $chr65 = chr(65); $chr97 = chr(97); $string =~ s/$chr65/$chr97/; print "$string\n"; #Input = 'ABC', Output = 'aBC'
Others seem to be able to quote these references directly inside a regex expression and have them be understood. I'm wondering if I might need to be referencing a specific package name in my script. Can anyone help?
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hexadecimal character references not understood inside a regex
by tobyink (Canon) on May 28, 2013 at 15:19 UTC | |
|
Re: Hexadecimal character references not understood inside a regex
by choroba (Cardinal) on May 28, 2013 at 15:18 UTC | |
|
Re: Hexadecimal character references not understood inside a regex
by Jim (Curate) on May 28, 2013 at 20:45 UTC |