The
translate( ) function looks in
s1 for any characters found in
s2. It replaces each character with the
corresponding character from
s3. For example,
translate("XML in a Nutshell",
" ", "_")
replaces the spaces with underscores and returns
"XML_in_a_Nutshell".
translate("XML in a
Nutshell", "XMLN", "xmln") replaces the
uppercase letters with lowercase letters and returns
"xml in
a nutshell". If
s3 is shorter than
s2, then characters in
s1 and
s2 with no corresponding character in
s3 are simply deleted. For example,
translate("XML in a Nutshell",
" ", "")
deletes the spaces and returns
"XMLinaNutshell".
Once again, nonstring objects may be passed to this function, in
which case they're automatically converted to
strings, as if by the
string( ) function.