I have been having an extremely trying 30 minutes or so, trying to regex out no-break space unicode entities, represented in my very large raw text file as \302\240. I was just about to post a request for some help, but figured out a solution to my problem. Perhaps it isn't the best solution, but I was unable to find anything concise which solved my problem, on the web, but I suppose there are others out there who have, or will have the same problem - so here's a very short, very simple solution:
#!/usr/bin/perl -w
use warnings;
use strict;
binmode(STDIN,":bytes");
binmode(STDOUT,":bytes");
while(<>){
chomp;
s/\302\240//g;
s/\s+/ /g;
print $_."\n";
}
This completely solved my problem. If it is incomplete, or not a very clever thing to do, please improve it. If it solves somebody elses problem as well - GREAT!
joe
2006-09-14 Retitled by planetscape, as per Monastery guidelines
( keep:0 edit:12 reap:0 )
Original title: 'Annoying Problem: solved'
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.