Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Replacing non ascii in string

by vinoth.ree (Monsignor)
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015958]
help
Chatterbox?
[davies]: LanX: No. The mayor of London would better be described as the transport commisar for London. S/h/it doesn't have a tenth of the power of La Sturgeon (and therefore does <10% of the damage).
[LanX]: xD ... complicated countrie(s)
LanX reigned by the Duke of Normandy
[davies]: LanX: Politicians making jobs for each other, really. Results in unnecessary complications and tax bills with up to 5 levels of Govt busily inventing new crimes for people to commit.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2017-12-15 18:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (441 votes). Check out past polls.

    Notices?