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. Advertisements

  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. Advertisements

  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. Advertisements

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. Sandeep Grover

    delete on delete !

    Sandeep Grover, Jul 12, 2003, in forum: C++
    Replies:
    19
    Views:
    935
    Chris \( Val \)
    Jul 22, 2003
  2. HeroOfSpielburg
    Replies:
    1
    Views:
    559
    Alf P. Steinbach
    Aug 6, 2003
  3. Kosio

    Floats to chars and chars to floats

    Kosio, Sep 16, 2005, in forum: C Programming
    Replies:
    44
    Views:
    1,859
    Tim Rentsch
    Sep 23, 2005
  4. RicK
    Replies:
    2
    Views:
    461
  5. Bernie
    Replies:
    1
    Views:
    758
    James Kanze
    Jun 13, 2008
  6. Hongyu
    Replies:
    9
    Views:
    1,243
    James Kanze
    Aug 8, 2008
  7. M.Posseth

    receiving ??? chars instead of "special" chars

    M.Posseth, Nov 15, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    510
    Dan Rogers
    Nov 16, 2004
  8. Patrick Flaherty

    Delete trailing garbage chars from a set of files?

    Patrick Flaherty, Jul 4, 2003, in forum: Perl Misc
    Replies:
    5
    Views:
    322
    Tad McClellan
    Jul 4, 2003
Loading...