http://www.perlmonks.org?node_id=1005560


in reply to Re: How to remove other language character from a string
in thread How to remove other language character from a string

Thanks moritz, but when I tried this I got the output like this:
α╕äα╕úα╕▒α╕ºα&# +9557;ïα╕¡α╕çα╣Çα╣Çα& +#9557;ïα╕Öα╕öα╣îα╕ºα +╕┤α╕èα╣äα╕éα╣ +êα╕öα╕▓α╕º Croissant Egg Sandwich α╕äα╕úα╕▒α&#9557 +;ºα╕ïα╕¡α╕çα╣Çα&#957 +1;Çα╕ïα╕Öα╕öα╣îα&#95 +57;ºα╕┤α╕èα╣äα╕é&#9 +45;╣êα╕öα╕▓α╕º

Replies are listed 'Best First'.
Re^3: How to remove other language character from a string
by frozenwithjoy (Priest) on Nov 26, 2012 at 05:51 UTC

    That's because it wasn't formatted correctly due to missing code tags (which were presumably left out so that the input text would be shown properly). When I first ran moritz's code, I just got the original string, but when I substituted:

    $str =~ s/[^\p{Latin}\s]//g;

    for this:

    $str =~ s/^\p{Latin}\s//g;

    it worked.

    EDIT: If you have lots of extra spaces in your output, you could run it through $str =~ s/ {2,}/ /g;, too. Something to keep in mind is that moritz's approach (as is) will remove punctuation.

      It worked smoothly. Thanks Frozenwithjoy and moritz.