Modules · Data · Text
Strings and the operations over them — measuring, comparing, searching, slicing, changing case, trimming, splitting and joining, padding, validating against character sets, formatting numbers, hashing, and URL encoding. Text values are the native Text type, which also groups these functions; every one is reactive, so a derived string recomputes whenever the values it reads change. Predicates such as Text.Contains return a Logic.Maybe , and the character-set constants pair with Text.AllowChars to sanitise input.
A string of characters: the built-in text type, which also groups the text functions and character-set constants.
The ASCII letters, upper and lower case.
The ASCII letters and digits.
The characters allowed in a database name.
The hexadecimal digits, upper and lower case.
The lowercase hexadecimal digits.
The uppercase hexadecimal digits.
The lowercase ASCII letters a to z.
The decimal digits 0 to 9.
The uppercase ASCII letters A to Z.
The characters allowed in a URL-safe name.
Keeps only the characters in an allowed set.
Returns Text — string with every character not in allowedChars removed.
Joins two or more strings end to end.
Returns Text — a and b joined end to end, followed by each of c through g that holds a value, in order.
Appends a second string only when it is present.
Returns Text — text , with optionalText appended when it holds a value.
The character at a position.
Returns Text — the character at pos , or optionalDefaultChar when out of range.
Yes when a substring occurs anywhere.
Returns Logic.Maybe — yes when needle occurs anywhere in haystack .
Yes when every character is allowed.
Returns Logic.Maybe — yes when every character of string is in allowedChars .
Emits a piece to the enclosing Gather.
Returns nothing — it adds piece to the enclosing Text.Gather .
Yes when the text has no characters.
Returns Logic.Maybe — yes when text has no characters.
Percent-encodes text for use in a URL.
Returns Text — input percent-encoded so it is safe inside a URL.
Yes when the text ends with a suffix.
Returns Logic.Maybe — yes when haystack ends with needle .
Yes when two strings are equal.
Returns Logic.Maybe — yes when a and b are exactly equal.
Formats a number with decimals and separators.
Returns Text — n formatted with the given decimal places and optional thousands separators.
Collects emitted pieces and joins them.
The block whose Text.Emit calls contribute the pieces to join.
Returns Text — the pieces emitted within its block, concatenated in order.
Collects emitted pieces and joins them with a separator.
Returns Text — the pieces emitted within its block, joined by separator .
The text between two markers.
Returns Collection.Optional(Text) — the text between the first a and the next b , or nothing when a is absent.
The text after the first marker.
Returns Collection.Optional(Text) — the part of str after the first substr , or nothing when absent.
The text before the first marker.
Returns Text — the part of haystack before the first needle .
The position of a substring, or -1.
Returns Maths.Integer — the index of the first needle at or after optionalOffset , or -1 when not found.
Blends one string into another by progress.
Returns Text — a blend of start and target set by progress .
Yes when the text is all lowercase letters.
Returns Logic.Maybe — yes when every character of text is a lowercase ASCII letter.
Yes when the text is empty or only whitespace.
Returns Logic.Maybe — yes when text is empty or contains only whitespace.
Joins an array of strings into one.
Returns Text — the elements concatenated, separated by optionalSeparator when given.
The number of characters in the text.
Returns Maths.Integer — the number of characters in text .
The text in lower case.
Returns Text — text with every letter lower-cased.
Yes when the text matches a regular expression.
Returns Logic.Maybe — yes when text matches the regular expression pattern .
Yes when the text has at least one character.
Returns Logic.Maybe — yes when text has at least one character.
Yes when two strings differ.
Returns Logic.Maybe — yes when a and b are not equal.
Runs its block when its value matches the enclosing Select.
The content to run when optionValue equals the value selected by the enclosing Text.Select .
Returns nothing — it runs its block only on a match.
Pads a string on the left to a length.
Returns Text — string padded on the left to length with optionalPadString .
Removes characters from the start or end.
Returns Text — text with num characters removed from the start, or from the end when negative.
Removes a suffix if present.
Returns Text — haystack with a trailing needle removed when present.
Removes a prefix if present.
Returns Text — haystack with a leading needle removed when present.
Replaces the first occurrence of a substring.
Returns Text — haystack with the first search replaced by replace .
Replaces every occurrence of a substring.
Returns Text — haystack with every search replaced by replace .
Opens a group that runs the matching Option for a string value.
An indented block of Text.Option entries; the one whose value equals value runs.
Returns nothing — it publishes value to the enclosed options over its block.
A hexadecimal digest of the text.
Returns Text — a hexadecimal digest string derived from input .
Divides a string into an array on a delimiter.
Returns Collection.Array(Text) — the pieces of string divided at each delimiter .
The first characters of a string.
Returns Text — the first length characters of text .
Yes when the text begins with a prefix.
Returns Logic.Maybe — yes when text begins with startsWith .
Extracts part of a string by position and length.
Returns Text — the slice of string from start , up to optionalLength characters.
Removes whitespace from both ends.
Returns Text — text with leading and trailing whitespace removed.
Removes trailing whitespace.
Returns Text — text with trailing whitespace removed.
Removes leading whitespace.
Returns Text — text with leading whitespace removed.
The text in upper case.
Returns Text — text with every letter upper-cased.
Capitalises the first letter of each word.
Returns Text — text with each word's first letter capitalised and the rest lower-cased.