in reply to Remove ÿþ from a string

I tried this: s/^\N{ZERO WIDTH NO-BREAK SPACE}//;

Works for me (unanchored):

#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 2; my $src = "foo\x{feff}bar"; my $res = $src; $res =~ s/\N{ZERO WIDTH NO-BREAK SPACE}//; isnt ($res, $src, 'Output differs from src'); is ($res, 'foobar', 'BOM stripped');

You can always add the anchor in if required (as the BOM should only occur at the start as Athanasius explained).