Mwnci tr() Function

Syntax

tr(string1,string2, string3)

Description

The tr() function substitutes characters in string1 using string2 as the list of characters to replace, with string3 being used as the list to use as the replacements.
The characters in string2 are translated into the characters in string3 where the first character in string2 is translated into the first character in string3 and so on. If string2 is longer than string3, the last character found in string3 is duplicated until string2 is exhausted.

Sequences can contain:

[:alnum:]   all letters an digits
[:alpha:]   all letters
[:blank:]   all horizontal whitespace
[:digit:]   all digits
[:graph:]   all printable characters, not including space
[:lower:]   all lower case letters
[:punct:]   all punctuation characters
[:space:]   all horizontal or vertical whitespace
[:upper:]   all upper case letters
[:word:]    all valid characters for a word (digit, upper, lower, "_")
[:xdigit:]  all hexadecimal digits (digit, A-F, a-f)

Example

include("main")
a="This is a string"
a=tr(a, "si", "SI")
println(a)
a=tr(a, "[:upper:]", "[:lower:]")
println(a)
a="This contains 3 numbers, not including the original number 3, I.e  2, 4, 7"
a=tr(a, "T[:digit:]", "t+")
println(a)


ThIS IS a StrIng
this is a string
this contains + numbers, not including the original number +, I.e  +, +, +