Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: How to remove other language character from a string

by Anonymous Monk
on Nov 26, 2012 at 05:36 UTC ( #1005560=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005560]
help
Chatterbox?
[Your Mother]: They would think so.
[jdporter]: ok, I need a recipe for piping lines "through" an external program which is itself a filter
[jdporter]: without using a tmp file
[1nickt]: tobyink perl -MTypes::Standard= is_Int -Mstrict -wE 'say 1 if is_Int 1.0'
[jdporter]: so that I can use the existing expand unix util. Otherwise, I'll probably use Text::Tabs.
[1nickt]: pryrt I guess I don;t really care if user 42 logs on as 42.0 ... more of an academic question at this point.
[LanX]: jdporter: open PIPE,'-|' ?
[LanX]: oh you want the result line by line?
[jdporter]: ok, LanX, then what?
[jdporter]: It doesn't have to be line by line. Just "my program" "writes" to the external prog and also/then "reads" from it.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2017-05-24 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?