IanD has asked for the wisdom of the Perl Monks concerning the following question:
OK I have searched and searched here and can't find a solution for this.
I have a string that contains copied and pasted text from word or some mac thing and it contains non ascii apostrophies and quotes.
eg (all in one long string):I want to replace all the ‘ and ’ with the ascii ' and the “ and ” with the ascii "Australia’s ‘Powder Capital’ and ... xxx said “This is a fantastic start to the season”
I can get rid of them with this:
$data_string =~s/[^[:ascii:]]//g;
But I want to replace them, not remove them and can't for the life of me work out the right regex to do this.
Also what reference do you use for the lookup. I have been using this:
http://www.ascii.cl/htmlcodes.htm
Which could be my problem. As down the track I am sure I will want to replace things like ä with a etc as well.
Thanks.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Replacing non ascii in string
by Kenosis (Priest) on Jan 30, 2013 at 05:04 UTC | |
Re: Replacing non ascii in string
by Athanasius (Archbishop) on Jan 30, 2013 at 04:38 UTC | |
by IanD (Initiate) on Jan 31, 2013 at 03:19 UTC | |
by Athanasius (Archbishop) on Jan 31, 2013 at 04:10 UTC | |
by IanD (Initiate) on Jan 31, 2013 at 05:21 UTC | |
by Anonymous Monk on Jan 31, 2013 at 08:41 UTC | |
by IanD (Initiate) on Feb 05, 2013 at 05:54 UTC | |
Re: Replacing non ascii in string
by Anonymous Monk on Jan 30, 2013 at 09:15 UTC | |
by MidLifeXis (Monsignor) on Jan 30, 2013 at 13:24 UTC | |
Re: Replacing non ascii in string
by vinoth.ree (Monsignor) on Jan 30, 2013 at 04:41 UTC | |
Re: Replacing non ascii in string
by naChoZ (Curate) on Jan 30, 2013 at 19:15 UTC |
Back to
Seekers of Perl Wisdom