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).
In reply to Re: Remove ÿþ from a string
by hippo
in thread Remove ÿþ from a string
by AnishaM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |