Removing numbers from a text file

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

  1. #1

    Default Removing numbers from a text file

    What would be the most efficient way to remove numbers from a text
    file.
    eg. I want "abcde123fghi" to be "abcdefghi". Should load the file
    into an array and create another file with characters that are not
    numbers? With 100k character file for example that could take awhile.
    Any suggestions?
    thank you.
    bob Guest

  2. Similar Questions and Discussions

    1. Removing street numbers
      I have a list of street addresses 1670 Oak Ave 1423 Harvest Wood Circle 32 Oak Hills Plaza Estates 2341 Main And I want to create a...
    2. Text numbers for checks, etc.
      Just ignore me if this has been gone over in depth before... Has anyone got a graceful calculation to turn numbers into their text equivalents...
    3. removing some text
      Hello, I know nothing about perl but have a perl script that I need to modify. The line below removes all web links but leaves the text in the...
    4. Please help me with removing text
      I have a logo from which I would like to delete the text. I would then like to copy the background to make it look like there was nothing there to...
    5. numbers to text
      Anyone know of a class or function that converts numbers to readable text eg inputing the number would output text as in 120 = one hundred and...
  3. #2

    Default Re: Removing numbers from a text file

    On 12 Sep 2003 19:42:25 -0700,
    bob <utsuxs@hotmail.com> wrote:
    > What would be the most efficient way to remove numbers from a text
    > file.
    (untested)

    $ perl -pi -e 's/\d//g' filename

    or

    $ perl -pi -e 'tr/0-9//d' filename

    There might be more efficient ways, but I don't think it's worth looking
    for them, so I won't.
    > eg. I want "abcde123fghi" to be "abcdefghi". Should load the file
    > into an array and create another file with characters that are not
    > numbers?
    Why should it load the file into an array?
    > With 100k character file for example that could take awhile.
    100k is nothing. Why do you think that "could take awhile'? What do you
    define as acceptible performance? I'm sure the above on a reasonable
    machine with 100k of input would run more than fast enough. Loading a
    100k into an array or scalar and then doing the same would not take much
    more or less time. In any case, it's unlikely you'd notice the
    difference.

    Martien
    --
    |
    Martien Verbruggen |
    | The gene pool could use a little chlorine.
    |
    Martien Verbruggen Guest

  4. #3

    Default Re: Removing numbers from a text file

    Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message
    > 100k is nothing. Why do you think that "could take awhile'? What do you
    > define as acceptible performance? I'm sure the above on a reasonable
    > machine with 100k of input would run more than fast enough. Loading a
    > 100k into an array or scalar and then doing the same would not take much
    > more or less time. In any case, it's unlikely you'd notice the
    > difference.
    >
    > Martien
    Thanks for your tips. I'm brand new to perl and I've been and windoze
    to long. I guess I've been corrupted.
    bob Guest

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