Skip to content

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).

Lower("Hello World")   // "hello world"
Upper("hello")         // "HELLO"

Trim(value)

Remove leading and trailing whitespace.

Trim("  hello  ")   // "hello"

StartsWith(value, prefix) · EndsWith(value, suffix)

Case-insensitive prefix / suffix check. Returns bool.

StartsWith(Path, "/shop")    // true for /shop/product/1
EndsWith(Host, ".nl")        // true for example.nl

Contains(value, substring)

Case-insensitive substring check. Returns bool.

Contains(Path, "product")

Replace(value, old, new)

Replace all occurrences of old with new. Case-sensitive.

Replace(Path, "/old/", "/new/")

Split(value, separator) · Join(array, separator)

Split a string into an array, or join an array back into a string.

Split("a,b,c", ",")        // ["a", "b", "c"]
Join(Split(Path, "/"), "-")

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.

IsInt(Segment(Path, 1))   // true for /items/5, false for /items/slug

ToInt(value)

Parse the string as an integer. Throws if the value is not a valid integer — use IsInt first.

ToInt(Segment(Path, 1)) > 100

IntBetween(value, min, max)

Returns true if the string parses as an integer within [min, max] inclusive.

IntBetween(Segment(Path, 1), 1, 9999)

Regex functions

Matches(input, pattern)

Returns true if the input matches the regular expression.

Matches(Path, @"^/product/\d+$")
Matches(Host, @"\.(nl|be|de)$")

Match(input, pattern, group)

Returns the value of a named capture group, or "" if the pattern does not match.

Match(Path, @"^/(?<lang>[a-z]{2})/", "lang")   // "en", "nl", ...

Map functions

Map(mapName, key)

Look up key in a static map. Returns the mapped value, or "" if the key is not found.

Map("products", Segment(Path, 1))

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.

MapOrDefault("campaigns", QueryParams["ref"], "default")

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.

DynMap("price-tier", Segment(Path, 2))