http://www.perlmonks.org?node_id=1035720


in reply to Hexadecimal character references not understood inside a regex

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 [sic].

If you're trying to match the Unicode byte order mark, then Perl must understand the text is Unicode and not in some other national or vendor coded character set. Does it? Show us more of your real code. I suspect your problem has less to do with hexadecimal escape sequences in regular expression patterns and more to do with decoding and encoding of input and output. Just a hunch…

There's also this idiom…

use charnames qw( :full ); m/\N{BYTE ORDER MARK}/;