Standard Library: Re
Use regular expressions to search and manipulate strings
As Pointless is currently implemented in JavaScript, it inherits some of the limitations of the UTF-16 encoding that JS uses, for example:
Re.test("☺", "^.$") -- '.' matches BMP character U+263A
Re.test("😀", "^.$") -- '.' doesn't match SMP character U+1F600
true
false
Re.escape(string)
Escape special characters in string so it can be used
as a literal in a regular expression.
Re.escape("Hello? Can you *hear* me??")
"Hello\\? Can you \\*hear\\* me\\?\\?"
Re.match(string, pattern)
Find the matches for pattern in string.
Return a table with the following columns:
value: The matched substring.-
index: Index ofvalueinstring. groups: List of captures.named: Object of named captures.
Re.match("nessa@example.com, megan@xkcd.com", r"(?<name>\w+)@(\w+\.\w+)")
┌───────────────────┬───────┬──────────────────────────┬───────────────────┐
│ value │ index │ groups │ named │ x 2
├───────────────────┼───────┼──────────────────────────┼───────────────────┤
│ nessa@example.com │ 0 │ ["nessa", "example.com"] │ { name: "nessa" } │
│ megan@xkcd.com │ 19 │ ["megan", "xkcd.com"] │ { name: "megan" } │
└───────────────────┴───────┴──────────────────────────┴───────────────────┘
Re.replace(string, pattern, replacement)
Replace all matches of pattern in
string with replacement.
Re.replace("2025 07 22", " +", ".")
"2025.07.22"
Re.replaceBy(string, pattern, replacer)
Replace all matches of pattern in
string with replacement.
Re.replaceBy("a catalog of cats", r"cat\w*", Str.toUpper)
"a CATALOG of CATS"
Re.split(string, pattern)
Split string using the regular expression
pattern. The matching separators are not included in
the resulting substrings.
Re.split("NYC NY USA", " +")
["NYC", "NY", "USA"]
Re.test(string, pattern)
Check whether string matches the regular expression
pattern.
Re.test("nessa@example.com", r".+@.+\..+")
Re.test("nessa at example dot com", r".+@.+\..+")
true
false