Eliminating 'weird' characters from fax id's

Eliminating 'weird' characters from fax id's

Post by pinoy_a » Thu, 11 Jan 1996 04:00:00



Hi,
        We have a fax package here that generates two files. An info file
        and the fax file. The info file contains the TSI of the sending party.
        I would like to extract just the numbers and letters and write
        them to a file. Here are some examples:

        From                            To

        +(123) 456-7890          --->   1234567890
        + (123) 456-7890         --->   1234567890
        + (123) 456 7890         --->   1234567890
        TRANS\260OCEAN           --->   TRANSOCEAN (the \260 is a ctrl(?) char)
        SW-TF-1                  --->   SWTF1

        Basically, I need something to remove all "[^A-Za-z0-9]" (Is this
        correct regex?) Can you help me with the command/s to do this? Pls.
        email or post. Thanks!
John
--
-------------------------------------------------------------------------------
- J -

 
 
 

Eliminating 'weird' characters from fax id's

Post by Craig Brent Ludingt » Thu, 11 Jan 1996 04:00:00


[ deletia ]
:       Basically, I need something to remove all "[^A-Za-z0-9]" (Is this
[ deletia ]

And, presumably, leave in the newlines. Try:

        tr -d -c '[A-Za-z0-9\n]' < input_file
            ^  ^
            |  |
            |  complement the character class
            |  
            | delete the specified characters

Regards,

Craig

 
 
 

Eliminating 'weird' characters from fax id's

Post by Heiner Stev » Sun, 14 Jan 1996 04:00:00


[...]
 >   From                            To
 >   +(123) 456-7890          --->   1234567890
 >   + (123) 456-7890         --->   1234567890
 >   + (123) 456 7890         --->   1234567890
 >   TRANS\260OCEAN           --->   TRANSOCEAN (the \260 is a ctrl(?) char)
 >   SW-TF-1                  --->   SWTF1

 >   Basically, I need something to remove all "[^A-Za-z0-9]"
 >   (Is this correct regex?) Can you help me with the
 >   command/s to do this? Pls.  email or post. Thanks!  John

Using your regular expression:

    sed 's:[^A-Za-z0-9]::g' IN > OUT

Heiner
--

World - Europe - Germany - Bavaria - Nuernberg

 
 
 

Eliminating 'weird' characters from fax id's

Post by User1003 » Mon, 29 Jan 1996 04:00:00


Use
sed 's/+()//g' input > output