|
Posted by Ralph Noble on October 7, 2004, 8:47 pm
Please log in for more thread options
Folks ... I have a pipe-delimited ASCII text file with a lot of
different non-printing characters. Rather than try and figure out all
the non-printing characters that exist in this 17+ million record
database, I was hoping someone might have already written a script or
know of a module they'd be willing to share that would remove all
non-printing characters from an ASCII file?
Thanks,
Ralph Noble
ralph_noble@hotmail.com
|
|
Posted by Jürgen Exner on October 8, 2004, 5:19 am
Please log in for more thread options
Ralph Noble wrote:
> Folks ... I have a pipe-delimited ASCII text file with a lot of
> different non-printing characters. Rather than try and figure out all
> the non-printing characters that exist in this 17+ million record
> database, I was hoping someone might have already written a script or
> know of a module they'd be willing to share that would remove all
> non-printing characters from an ASCII file?
Oh my, that's difficult. you need one whole command:
s/[:^print:]//g;
Further details see "perldoc perlre", section " The POSIX character class
syntax".
Reading the file and writing back the modified text is left as an exercise.
jue
|
|
Posted by Brian McCauley on October 8, 2004, 7:30 pm
Please log in for more thread options Jürgen Exner wrote:
> s/[:^print:]//g;
Surely you mean
s/[^[:print:]]+//g;
> Further details see "perldoc perlre", section " The POSIX character class
> syntax".
Right back at you J! :-)
|
|
Posted by Jürgen Exner on October 8, 2004, 7:47 pm
Please log in for more thread options Brian McCauley wrote:
> Jürgen Exner wrote:
>
>> s/[:^print:]//g;
>
> Surely you mean
>
> s/[^[:print:]]+//g;
>
>> Further details see "perldoc perlre", section " The POSIX character
>> class syntax".
>
> Right back at you J! :-)
Hmmmm, indeed ;-((
jue
|
|
Posted by Brian McCauley on October 8, 2004, 7:22 pm
Please log in for more thread options Ralph Noble wrote:
> Folks ... I have a pipe-delimited ASCII text file with a lot of
> different non-printing characters. Rather than try and figure out all
> the non-printing characters that exist in this 17+ million record
> database, I was hoping someone might have already written a script or
> know of a module they'd be willing to share that would remove all
> non-printing characters from an ASCII file?
perl -pe 's/[[:cntrl:]]+//g'
(Note this removes all nonprinting characters including the linebreaks
too - is that really what you wanted?)
perl -lpe 's/[[:cntrl:]]+//g'
|
| Similar Threads | Posted | | handling UTF-8 characters in LWP module | August 31, 2006, 10:39 pm |
| replacing nonprintable characters in a file | June 3, 2005, 4:21 pm |
| replacing characters with their ASCII codes | August 20, 2005, 8:50 pm |
| regular expression problem ? and * characters | May 28, 2006, 7:02 am |
| Spreadsheet::Read special characters handling | November 20, 2006, 2:33 am |
| Print Subject without characters Just Numbers using POP3Client. Please Help | April 10, 2007, 11:27 pm |
| Do Win32::ODBC module support Chinese characters when used with MS Access? | September 15, 2004, 10:33 pm |
| XP, Perl, Win32::ODBC, Microsoft Access 2002 SP3, & Chinese characters | January 22, 2008, 4:18 pm |
|