Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How Do I Use the tr Function's 'c' Option?

by halley (Prior)
on Aug 24, 2005 at 16:34 UTC ( [id://486276]=note: print w/replies, xml ) Need Help??


in reply to How Do I Use the tr Function's 'c' Option?

When in doubt, trust the actual Perl documentation over any other website. Type "perldoc perlop" at your command line.

The issue with the unofficial documentation you found is that tr does not take special regular expression escapes like "\d" or bracketed classes like "[abc]" in its arguments.

    Note that "tr" does not do regular expression character classes such as "\d" or "[:lower:]".
$string =~ tr/0123456789/ /c;
It does support ranges, but use no brackets. Shortcut the above with the special hyphen:
$string =~ tr/0-9/ /c;

--
[ e d @ h a l l e y . c c ]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://486276]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-24 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found