Functions¶
Functions can be called inside match expressions and extract expressions. All string comparisons are case-insensitive unless noted otherwise.
String functions¶
Lower(value) · Upper(value)¶
Convert a string to lower or upper case (invariant culture).
Trim(value)¶
Remove leading and trailing whitespace.
StartsWith(value, prefix) · EndsWith(value, suffix)¶
Case-insensitive prefix / suffix check. Returns bool.
Contains(value, substring)¶
Case-insensitive substring check. Returns bool.
Replace(value, old, new)¶
Replace all occurrences of old with new. Case-sensitive.
Split(value, separator) · Join(array, separator)¶
Split a string into an array, or join an array back into a string.
Segment(path, index)¶
Extract a path segment by zero-based index. Returns "" if the index is out of range.
Segments are split on /; empty segments (from leading slash) are ignored.
// Path = "/shop/product/42"
Segment(Path, 0) // "shop"
Segment(Path, 1) // "product"
Segment(Path, 2) // "42"
Numeric functions¶
IsInt(value)¶
Returns true if the string can be parsed as an integer.
ToInt(value)¶
Parse the string as an integer. Throws if the value is not a valid integer — use IsInt first.
IntBetween(value, min, max)¶
Returns true if the string parses as an integer within [min, max] inclusive.
Regex functions¶
Matches(input, pattern)¶
Returns true if the input matches the regular expression.
Match(input, pattern, group)¶
Returns the value of a named capture group, or "" if the pattern does not match.
Map functions¶
Map(mapName, key)¶
Look up key in a static map. Returns the mapped value, or "" if the key is not found.
Missing keys
Map() returns "" for missing keys — it does not throw. Use the Tester to diagnose empty results; it will tell you exactly which key was not found.
MapOrDefault(mapName, key, fallback)¶
Same as Map(), but returns fallback instead of "" when the key is not found. Also returns fallback if the map itself does not exist.
DynMap(mapName, inputValue)¶
Look up inputValue in a dynamic map. Entries are evaluated in order; the first matching entry's result template is returned. Returns "" if no entry matches.