From: Bertram Scharpf Date: 2005-03-21T20:25:36+09:00 Subject: Re: string.tr and \ Hi, Am Montag, 21. M�r 2005, 19:43:18 +0900 schrieb Tom Counsell: > I'm a little confused and would appreciate your help. I would like to > remove any \ characters from a string as well as some other characters. > > 'b\\c['.tr('\\','') # => 'bc', which is great. > > 'b\\c'.tr('\\c','.') # => 'b\\' which is not great. > > Why does adding extra characters to the tr function stop the removal of > \ characters? The backslash needs to be escaped: 'b\\c'.tr '\\\\c', '.' As far as I know there's no way to avoid escaping an \ in string literals. Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de