Removing non-printing characters ...

Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default Removing non-printing characters ...

    Folks ... I have a pipe-delimited ASCII text file with a lot of
    different non-printing characters. Rather than try and figure out all
    the non-printing characters that exist in this 17+ million record
    database, I was hoping someone might have already written a script or
    know of a module they'd be willing to share that would remove all
    non-printing characters from an ASCII file?

    Thanks,

    Ralph Noble
    [email]ralph_noble@hotmail.com[/email]
    Ralph Noble Guest

  2. Similar Questions and Discussions

    1. Removing special characters from a string
      What's the best way to remove special characters from a string leaving just alphanumeric characters and spaces ???
    2. Removing characters out of a field
      I have a search screen and the user will be entering an isbn number to search. Some users will enter dashes and others will not. My database field...
    3. Characters looking jumbled when printing
      Hi Guys, we have recently sent a pdf file to a client which opens up fine for us and prints for us, when the client opens the file it looks great on...
    4. Finding non-printing characters in data
      HP-UX 11.0 IDS 9.21.HC4 Just wondering if there is a simple way to find non-printing characters embedded in char fields. I have tried to...
    5. Removing characters once a series stops
      I have strings that I need to get the first set of numbers from. IE: ABC123DEF ABC11JH8KLZ I need to get 123 and 11 from the from the above...
  3. #2

    Default Re: Removing non-printing characters ...

    Ralph Noble wrote:
    > Folks ... I have a pipe-delimited ASCII text file with a lot of
    > different non-printing characters. Rather than try and figure out all
    > the non-printing characters that exist in this 17+ million record
    > database, I was hoping someone might have already written a script or
    > know of a module they'd be willing to share that would remove all
    > non-printing characters from an ASCII file?
    Oh my, that's difficult. you need one whole command:

    s/[:^print:]//g;

    Further details see "perldoc perlre", section " The POSIX character class
    syntax".
    Reading the file and writing back the modified text is left as an exercise.

    jue


    Jürgen Exner Guest

  4. #3

    Default Re: Removing non-printing characters ...

    Ralph Noble wrote:
    > Folks ... I have a pipe-delimited ASCII text file with a lot of
    > different non-printing characters. Rather than try and figure out all
    > the non-printing characters that exist in this 17+ million record
    > database, I was hoping someone might have already written a script or
    > know of a module they'd be willing to share that would remove all
    > non-printing characters from an ASCII file?
    perl -pe 's/[[:cntrl:]]+//g'

    (Note this removes all nonprinting characters including the linebreaks
    too - is that really what you wanted?)

    perl -lpe 's/[[:cntrl:]]+//g'


    Brian McCauley Guest

  5. #4

    Default Re: Removing non-printing characters ...

    Jürgen Exner wrote:
    > s/[:^print:]//g;
    Surely you mean

    s/[^[:print:]]+//g;
    > Further details see "perldoc perlre", section " The POSIX character class
    > syntax".
    Right back at you J! :-)

    Brian McCauley Guest

  6. #5

    Default Re: Removing non-printing characters ...

    Brian McCauley wrote:
    > Jürgen Exner wrote:
    >
    >> s/[:^print:]//g;
    >
    > Surely you mean
    >
    > s/[^[:print:]]+//g;
    >
    >> Further details see "perldoc perlre", section " The POSIX character
    >> class syntax".
    >
    > Right back at you J! :-)
    Hmmmm, indeed ;-((

    jue


    Jürgen Exner Guest

  7. #6

    Default Re: Removing non-printing characters ... Does this remove newlines too?

    It shouldn't right? I tried using this and piping to output file, but for some reason, it returns one long line instead of my original format with many lines.
    Mary Pastore is offline Junior Member
    Join Date
    Dec 2010
    Posts
    1

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139