String class in Global context

String functions library.

9 members:

type and namedescriptioncomments
function len
function
string length String.len("abcdef") -> 6 
function replace
function
replace String.replace("abcdef","cd","X") -> "abXef" 
function split
function
split return the vector of substrings, cut at separator positions.
subsequent separators give empty words: split("word1---word2-word3","-") -> ["word1","","","word2","word3"] 
function split2
function
split2 return the vector of substrings, cut at separator positions.
subsequent separators are treated as one: split("word1---word2-word3","-") -> ["word1","word2","word3"] 
function indexOf
function
search for substring String.indexOf("abcdef","cd") -> 2
String.indexOf("abcdef","dc") -> -1
 
function substr
function
substring String.substr("abcdef",3,2) -> ="de" 
function left
function
left substring String.left("abcdef",3) -> ="abc" 
function right
function
right substring String.right("abcdef",3) -> ="def" 
function format
function
formatted string conversion Works like the standard C library "sprintf()" but only one %-argument is accepted.
Format string: %[-][+][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
Examples:
String.format("|%07.2f|",Math.pi) -> ="|0003.14|"
String.format("|%04x|",255) -> ="|00ff|"
String.format("|%7s|","text") -> ="| text|"
String.format("|%-7d|",12345) -> ="|12345 |"
 

Global context