| id | stdlib-string |
|---|---|
| title | String Module |
| slug | /stdlib/string |
Argument order is oldValue -> newValue -> source.
Replaces all non-overlapping occurrences using ordinal, case-sensitive matching. An empty oldValue returns source unchanged; an empty newValue removes matches. This operation always returns a string.
let text = String.replace "-" "_" "a-b-c"Argument order is value -> source. Matching is ordinal and case-sensitive; returns the first zero-based index or None when absent.
let maybeIndex = String.indexOf "script" "fscript"Converts a string to lowercase using invariant casing.
let lower = String.toLower "FSCRIPT"Converts a string to uppercase using invariant casing.
let upper = String.toUpper "fscript"Argument order is start -> length -> source.
Returns None for invalid ranges.
let maybeSub = String.substring 0 4 "fscript"Joins a list of strings with a separator.
let joined = String.concat "," ["a"; "b"; "c"]Argument order is separator -> source.
Splits on the exact separator string and preserves empty entries, including trailing ones.
let parts = String.split "," "a,b,c"Argument order is suffix -> source.
Checks whether the source ends with the suffix.
let isScript = String.endsWith ".fss" "samples/hello.fss"Whitespace helpers use a fixed Unicode White_Space set on every runtime: U+0009–000D, U+0020, U+0085, U+00A0, U+1680, U+2000–200A, U+2028–2029, U+202F, U+205F, and U+3000. U+FEFF is preserved.
Count/size arguments must fit 0..2147483647; chunk sizes must also be positive. Invalid arguments raise script errors. Collection callbacks run in the documented order and may themselves have effects; these helpers are pure when their callbacks are pure.
String.length : string -> intReturns the number of UTF-16 code units, not Unicode characters or grapheme clusters.
String.length "abc"
// 3String.isEmpty : string -> boolTests whether the string has zero length.
String.isEmpty ""
// trueString.isWhiteSpace : string -> boolTests whether the string is empty or consists only of Unicode whitespace.
String.isWhiteSpace " \t"
// trueString.trim : string -> stringRemoves Unicode whitespace from both ends.
String.trim " hi "
// "hi"String.trimStart : string -> stringRemoves leading Unicode whitespace.
String.trimStart " hi "
// "hi "String.trimEnd : string -> stringRemoves trailing Unicode whitespace.
String.trimEnd " hi "
// " hi"String.splitLines : string -> string listSplits CRLF, LF, or CR line endings. Empty and trailing lines are preserved; empty input produces [""].
String.splitLines "a\nb\n"
// ["a";"b";""]String.startsWith : string -> string -> boolTests an ordinal, case-sensitive prefix.
String.startsWith "ab" "abc"
// trueString.contains : string -> string -> boolTests for an ordinal, case-sensitive substring. The empty substring matches every string.
String.contains "b" "abc"
// trueString.padLeft : int -> string -> stringPads on the left with spaces to the requested UTF-16 width. Strings already at least that wide are unchanged.
String.padLeft 3 "a"
// " a"String.padRight : int -> string -> stringPads on the right with spaces to the requested UTF-16 width. Strings already at least that wide are unchanged.
String.padRight 3 "a"
// "a "String.repeat : int -> string -> stringConcatenates the string the requested number of times. Zero produces the empty string.
String.repeat 3 "ab"
// "ababab"String.compare : string -> string -> intReturns -1, 0, or 1 using ordinal UTF-16 ordering, independently of culture. This is useful for custom comparers over records.
String.compare "a" "b"
// -1