String class, available in: Global contextString functions library.This class has 33 members:
sdleiF
string ESC ROEscape character
string NBSP RONon-breaking space character
string SERIALIZATION_PREFIX ROSerialization prefixString prefix used in the Framsticks file format to indicate object fields that contain serialized objects.
snoitcnuF
function char(int)returns stringCharacter from ASCII
function code(string)returns intASCII code of the character
function deserialize(string)returns untypedDeserializeExtracts objects from textual representation. Error object is returned if deserialization fails.
Example:
var ret=String.deserialize(something);
if (typeof(ret)=="Error") Simulator.print("something is wrong: "+ret.message);
function diff(string, string)returns VectorCalculate string differenceReturns the vector of minimal differences between two strings. The vector contains either 2-element subvectors with differing substrings ["text-1","text-2"] or strings "same".

For example, String.diff("thisisatest", "testing123testing") returns [t,[hi,e],s,[,t],i,[sa,ng123],test,[,ing]].

Use this function for short strings, as it requires 4*length(string1)*length(string2) bytes of memory.
function endsWith(string string, string substring)returns intTest if ends with substring
function format(string format_string, untyped value_or_vector)returns stringFormatted string conversionWorks like the standard C library "sprintf()". The '%' operator can be used as a shortcut, e.g. String.format("%x",123) is equivalent of "%x" % 123
Character seqences beginning with % found in the format string are replaced by formatted values produced according to their corresponding format specifiers: %[-][+][0][width[.precision]]type
-: left adjust (default is right adjust)
+: place a sign (+ or -) before a number
0: the value should be zero padded
width: minimum field width
precision: minimum number of decimal digits
type: d=decimal integer, x/X=hexadecimal integer, f/g=floating point number, e="scientific" style floating point, c=character of a given ascii code, t=time, %=special case, outputs the literal % character
Multiple values can be formatted in one call, by passing a vector as the second argument:
String.format("a=%03d b=%.2f c=%s",[a,b,c]) or "a=%03d b=%.2f c=%s" % [a,b,c]
Alternatively, if no % characters are required in the output string, the chained call can be used:
"a=%03d b=%.2f c=%s" % a % b % c
The above expression works as expected, because, unlike the regular sprintf, the formatting function preserves % characters left after using all input arguments:
input: "a=%03d b=%.2f c=%s" % a % b % c
actual meaning: (("a=%03d b=%.2f c=%s" % a) % b) % c
phase 1: ("a=000 b=%.2f c=%s" % b) % c
phase 2: "a=000 b=0.00 c=%s" % c
result: "a=000 b=0.00 c=0"

Examples:
String.format("|%07.2f|",Math.pi) == "|0003.14|"
String.format("|%04x|",255) == "|00ff|"
String.format("|%7s|","text") == "| text|"
String.format("|%-7d|",12345) == "|12345 |"
String.format("%t",Math.time) == "Sun Apr 29 19:22:02 2007"
String.format("%T",Math.time) == "2007-05-29 19:22:02"
String.format("x=%d%%",100) == "100%"
function hash(string)returns intCompute 32-bit hash
function indexOf(string, string substring)returns intSearch for substringString.indexOf("abcdef","cd") == 2
String.indexOf("abcdef","dc") == -1
function indexOfStart(string, string substring, int start_index)returns intSearch for substringString.indexOfStart("abcdef","cd",1) == 2
String.indexOfStart("abcdef","cd",3) == -1
function left(string, int number_of_characters)returns stringLeft substringString.left("abcdef",3) == "abc"
function len(string)returns intString lengthString.len("abcdef") == 6
function parseFloat(string)returns floatParse floating pointIf the supplied string is not a number, returns 0.0 and posts an error message.
function parseInt(string)returns intParse integerIf the supplied string is not an integer, returns 0 and posts an error message.
function parseNumber(string)returns untypedParse integer or floating pointReturns an integer, a floating point, or null if the string cannot be parsed as a number.
The 'typeof' operator can be used to distinguish between an integer and a floating point value:
typeof(String.parseNumber("qwerty")) == "null"
typeof(String.parseNumber("1234")) == "int"
typeof(String.parseNumber("3.14")) == "float"
function quoteEof(string)returns stringquote eofAdd leading backslash to lines containing just 'eof' (or previously quoted 'eof') (for use in the network protocol implementation)
function replace(string input_string, string search, string substitute)returns stringReplaceString.replace("abcdef","cd","X") == "abXef"
function right(string, int number_of_characters)returns stringRight substringString.right("abcdef",3) == "def"
function serialize(untyped)returns stringSerializeConverts to textual representation, preserving object hierarchy.
function split(string text_to_split, string word_separator)returns VectorSplitreturn the vector of substrings, cut at separator positions.
subsequent separators give empty words:
split("word1---word2-word3","-") returns ["word1","","","word2","word3"]
function split2(string text_to_split, string word_separator)returns VectorSplit, merging separators firstreturn the vector of substrings, cut at separator positions.
subsequent separators are treated as one:
split2("word1---word2-word3","-") returns ["word1","word2","word3"]
function startsWith(string string, string substring)returns intTest if starts with substring
function substr(string, int first_character, int number_of_characters)returns stringSubstringString.substr("abcdef",3,2) == "de"
function substr(string, int first_character)returns stringsubstringString.substr("abcdef",3) == "def"
function toJSON(untyped)returns stringJSON serializationExports to JSON format, preserving object hierarchy (excluding recursion).
function toLower(string)returns stringMake lowercase version
function toUpper(string)returns stringMake uppercase version
function trim(string)returns stringRemoves whitespace from both sides of a string.
function unquoteEof(string)returns stringunquote eofRemove one level of backslash quoting from lines containing quoted 'eof' (for use in the network protocol implementation)
function urlDecode(string)returns stringURL decode
function urlEncode(string)returns stringURL encode
Global context