Delete not readable characters

Hi All,

I wanted to delete all the unwanted characters in the string. ie, to delete all the characters which are not alpha numeric values.

var1="a./bc"
var2='abc/\."123'

like to get the output as
print var1
abc
print var2
abc123

Could you guys help me out pls.
Your help is appreciated.

Thanks in advance.

With tr for example:

echo 'abc/\."123'| tr -d './\\"'
abc123

You have to something like this:

var=<something strange>
var=`echo $var | tr -dc 'a-zA-Z0-9'` 

The -c option complements the character set (a-zA-Z0-9) and the -d removes all matching characters. The backtic operators read the output back into the expression so that var again has the new value.

In bash or ksh93, to remove non-alphanumeric characters:

printf "%s\n" "${var1//[!a-zA-Z0-9]/}"