Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove "�" from a string 1

Status
Not open for further replies.

NetworkGhost

IS-IT--Management
Apr 12, 2005
1,324
US
Anyone now of anyway to remove special chacters like these "�" out of a string? There are other special chacters I would like to maintain. Just want to get rid of these ones. I was using TCL regsub but couldnt get it to work. Would really like to get this resolved.

Thanks

 
This approach
Code:
 echo  "asdf�jklö" | sed 's/[^a-zA-Z0-9\t\n;+#_-]//g'
asdfïjklö
removes ¿½ but not ïö - maybe "a-z" is interpreted as :alpha:, and therefore including all lowercase letters?
Let's see:
Code:
 echo  "asdf�jklöJKLÖ" | sed 's/[^abcdefghijklmnopqrstuvwxyz0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ\t\n;+#_-]//g'
asdfjkl
The special character section isn't complete, but you got the idea.

don't visit my homepage:
 
I usually use tr -d with the octal \XXX code if it is single characters.
pipe the string to od -c to see the values of the offenders.
 


Try this:

echo "GARBAGE" | sed -e 's/[^ -~]//g' | read new_var

The sed search string basically is "NOT printable character
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top