Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: Filtering unwanted chars from input field

by johngg (Abbot)
on Dec 18, 2012 at 14:14 UTC ( #1009372=note: print w/replies, xml ) Need Help??


in reply to Re^3: Filtering unwanted chars from input field
in thread Filtering unwanted chars from input field

That will work ok.

$ perl -E ' > @data = ( > q{Hello, world!}, > q{te-st%$/*.}, > q{All_of_this_is_OK.}, > q{!@#$%^&*()12345}, > ); > say for map { tr{A-Za-z0-9_.-}{}cd; $_ } @data;' Helloworld te-st. All_of_this_is_OK. 12345 $

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^5: Filtering unwanted chars from input field
by Anonymous Monk on Dec 19, 2012 at 20:51 UTC
    What is I want to allow spaces as well? \s+ does not work.

      The left hand side of the tr is not a regular expression. Just include a real space in the character list.

      $ perl -E ' > @data = ( > q{Hello, world!}, > q{te-st%$/*.}, > q{All_of_this_is_OK.}, > q{!@#$%^&*()12345}, > ); > say for map { tr{A-Za-z0-9_. -}{}cd; $_ } @data;' Hello world te-st. All_of_this_is_OK. 12345 $

      Cheers,

      JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009372]
help
Chatterbox?
[Corion]: ... and one thing leads to another, so ambrus provided the integration with AnyEvent so I can now conveniently make HTTP requests from that app too :)
[Corion]: I'm afraid that I'll turn off dk some day with all my bug reports or stuff that could be documented better ;-)

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2016-12-09 09:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (150 votes). Check out past polls.