Delete nonprinting chars

Discussion in 'Perl Misc' started by fishfry, Sep 6, 2004.

  1. fishfry

    fishfry Guest

    I know this is in the book but I can't find it at the moment ...

    what's the clever way to remove all nonprinting characters from a string?
    fishfry, Sep 6, 2004
    #1
    1. Advertising

  2. fishfry

    Ben Morrow Guest

    Quoth fishfry <>:
    > I know this is in the book but I can't find it at the moment ...
    >
    > what's the clever way to remove all nonprinting characters from a string?


    perldoc perlre
    perldoc perlop

    $string =~ s/[^[:print:]]//g;

    Ben

    --
    It will be seen that the Erwhonians are a meek and long-suffering people,
    easily led by the nose, and quick to offer up common sense at the shrine of
    logic, when a philosopher convinces them that their institutions are not based
    on the strictest morality. [Samuel Butler, paraphrased]
    Ben Morrow, Sep 6, 2004
    #2
    1. Advertising

  3. fishfry wrote:
    > I know this is in the book but I can't find it at the moment ...
    >
    > what's the clever way to remove all nonprinting characters from a
    > string?


    From "perldoc perlre":

    The POSIX character class syntax

    [:class:]

    is also available. The available classes and their backslash equivalents
    (if available) are as follows:
    [...]
    print
    [...]

    jue
    Jürgen Exner, Sep 6, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kosio

    Floats to chars and chars to floats

    Kosio, Sep 16, 2005, in forum: C Programming
    Replies:
    44
    Views:
    1,285
    Tim Rentsch
    Sep 23, 2005
  2. RicK
    Replies:
    2
    Views:
    369
  3. Bernie
    Replies:
    1
    Views:
    681
    James Kanze
    Jun 13, 2008
  4. Hongyu
    Replies:
    9
    Views:
    902
    James Kanze
    Aug 8, 2008
  5. M.Posseth

    receiving ??? chars instead of "special" chars

    M.Posseth, Nov 15, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    226
    Dan Rogers
    Nov 16, 2004
Loading...

Share This Page