G'day BernieC,
Regex issues:
-
Your first regex, s/^\xef\xbb\xbf//g, anchors to the start of the string:
later ef bb bf sequences will not be removed.
-
Your second regex, s/\xef\xbb\xbf//, has no /g modifier:
only the first ef bb bf sequence will be removed.
What you need is s/\xef\xbb\xbf//g:
$ perl -Mstrict -Mwarnings -E '
my $x = "\x{ef}\x{bb}\x{bf}123,,,\x{ef}\x{bb}\x{bf}456";
say "Full string:";
system "echo $x | hexdump -Cv";
$x =~ s/\xef\xbb\xbf//g;
say "All BOM sequences removed:";
system "echo $x | hexdump -Cv";
'
Full string:
00000000 ef bb bf 31 32 33 2c 2c 2c ef bb bf 34 35 36 0a |...123,,,
+...456.|
00000010
All BOM sequences removed:
00000000 31 32 33 2c 2c 2c 34 35 36 0a |123,,,456
+.|
0000000a
To remove other characters:
-
Non ISO-8859-1: y/\x00-\xff//cd
-
Non 7-bit ASCII: y/\x00-\x7f//cd
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.