String Module
Hosted interpreter permissions: Every function and value on this page requires no host permissions. Higher-order functions still enforce the requirements of their callbacks. These checks do not apply to CLI execution or compilation. See Host permissions.
String.replace : string -> string -> string -> string
None
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"
String.indexOf : string -> string -> int option
None
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"
String.toLower : string -> string
None
Converts a string to lowercase using invariant casing.
let lower = String.toLower "FSCRIPT"
String.toUpper : string -> string
None
Converts a string to uppercase using invariant casing.
let upper = String.toUpper "fscript"
String.substring : int -> int -> string -> string option
None
Argument order is start -> length -> source.
Returns None for invalid ranges.
let maybeSub = String.substring 0 4 "fscript"
String.concat : string -> string list -> string
None
Joins a list of strings with a separator.
let joined = String.concat "," ["a"; "b"; "c"]
String.split : string -> string -> string list
None
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"
String.endsWith : string -> string -> bool
None
Argument order is suffix -> source.
Checks whether the source ends with the suffix.
let isScript = String.endsWith ".fss" "samples/hello.fss"
Pure support additions
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
None
String.length : string -> int
Returns the number of UTF-16 code units, not Unicode characters or grapheme clusters.
String.length "abc"
// 3
String.isEmpty
None
String.isEmpty : string -> bool
Tests whether the string has zero length.
String.isEmpty ""
// true
String.isWhiteSpace
None
String.isWhiteSpace : string -> bool
Tests whether the string is empty or consists only of Unicode whitespace.
String.isWhiteSpace " \t"
// true
String.trim
None
String.trim : string -> string
Removes Unicode whitespace from both ends.
String.trim " hi "
// "hi"
String.trimStart
None
String.trimStart : string -> string
Removes leading Unicode whitespace.
String.trimStart " hi "
// "hi "
String.trimEnd
None
String.trimEnd : string -> string
Removes trailing Unicode whitespace.
String.trimEnd " hi "
// " hi"
String.splitLines
None
String.splitLines : string -> string list
Splits CRLF, LF, or CR line endings. Empty and trailing lines are preserved; empty input produces [""].
String.splitLines "a\nb\n"
// ["a";"b";""]
String.startsWith
None
String.startsWith : string -> string -> bool
Tests an ordinal, case-sensitive prefix.
String.startsWith "ab" "abc"
// true
String.contains
None
String.contains : string -> string -> bool
Tests for an ordinal, case-sensitive substring. The empty substring matches every string.
String.contains "b" "abc"
// true
String.padLeft
None
String.padLeft : int -> string -> string
Pads 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
None
String.padRight : int -> string -> string
Pads 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
None
String.repeat : int -> string -> string
Concatenates the string the requested number of times. Zero produces the empty string.
String.repeat 3 "ab"
// "ababab"
String.compare
None
String.compare : string -> string -> int
Returns -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