String class in Global context

String functions library.

16 members:

function char
returns string

character from ASCII

function char(integer)
function code
returns integer

ASCII code of the characte

function code(string)
function format
returns string

formatted string conversion

function format(string format, untyped value)

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, t=time
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"

function indexOf
returns integer

search for substring

function indexOf(string, string substring)

String.indexOf("abcdef","cd") -> 2
String.indexOf("abcdef","dc") -> -1

function indexOfStart
returns integer

search for substring

function indexOfStart(string, string substring, integer start_index)

String.indexOfStart("abcdef","cd",1) -> 2
String.indexOfStart("abcdef","cd",3) -> -1

function left
returns string

left substring

function left(string, integer number_of_characters)

String.left("abcdef",3) -> ="abc"

function len
returns integer

string length

function len(string)

String.len("abcdef") -> 6

function parseFloat
returns float

parse floating point

function parseFloat(string)
function parseInt
returns integer

parse integer

function parseInt(string)
function replace
returns string

replace

function replace(string search, string substitute)

String.replace("abcdef","cd","X") -> "abXef"

function right
returns string

right substring

function right(string, integer number_of_characters)

String.right("abcdef",3) -> ="def"

function split
returns Vector

split

function split(string, string word_separator)

return the vector of substrings, cut at separator positions.
subsequent separators give empty words: split("word1---word2-word3","-") -> ["word1","","","word2","word3"]

function split2
returns Vector

split2

function split2(string, string word_separator)

return the vector of substrings, cut at separator positions.
subsequent separators are treated as one: split2("word1---word2-word3","-") -> ["word1","word2","word3"]

function substr
returns string

substring

function substr(string, integer first_character, integer number_of_characters)

String.substr("abcdef",3,2) -> ="de"

function toLower
returns string

make lowercase version

function toLower(string)
function toUpper
returns string

make uppercase version

function toUpper(string)

Global context