Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Control characters

by JavaFan (Canon)
on Jun 05, 2009 at 12:28 UTC ( #768777=note: print w/replies, xml ) Need Help??


in reply to Control characters

Control characters are three stroke tokens, \cA, \cB, etc. You cannot put parts of the tokens and put them into a character class. Use:
s/[\cA-\cZ]+//g;
or an equivalent tr construct.

Note also that your use of ^ means you are only going to replace matches at the beginning of the string - at most one character in your example. Which from your description doesn't seem to be want you want.

Replies are listed 'Best First'.
Re^2: Control characters
by AnomalousMonk (Archbishop) on Jun 05, 2009 at 17:11 UTC
    From the OP, it's not entirely clear (at least, to me) just what the OPer wants, but if all control characters are to be deleted, the substitution  s/[[:cntrl:]]+//g; might better serve: the POSIX character class syntax responds to one or both (I forget which) of Unicode and locale variations.

    And, of course, the other point to make to the OPer is that the character set  [\cA-\cZ] does not represent all control characters even in the ASCII character set.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2023-12-11 05:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (41 votes). Check out past polls.

    Notices?