Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Replacing non ascii in string

by vinoth.ree (Prior)
on Jan 30, 2013 at 04:41 UTC ( #1015958=note: print w/ replies, xml ) Need Help??


in reply to Replacing non ascii in string

This will remove the non ascii characters,also creates backup file in file.backup file.

You can do the job with a perl one liner:   perl -i.backup -pe 's/[[:^ascii:]]//g;' file

Also, $str =~ s/[^!-~\s]//g; In the above, !-~ is a range which matches all characters between ! and ~. The range is set between ! and ~ because these are the first and last characters in the ASCII table.This does not include whitespace, so i added \s also.


Comment on Re: Replacing non ascii in string
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015958]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (13)
As of 2015-07-02 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (34 votes), past polls