RegExp
Regular expressions.
Always available
No import needed. These names are in scope in every file.
RegExp class
ts
class RegExplastIndex advances after exec when the g flag is set, matching JS semantics.
RegExp.dotAll
ts
readonly dotAll: booleanTrue if the s (dotAll) flag is set; . matches newlines.
RegExp.flags
ts
readonly flags: stringThe flag string (e.g., "gi" for global and ignoreCase).
RegExp.global
ts
readonly global: booleanTrue if the g (global) flag is set.
RegExp.ignoreCase
ts
readonly ignoreCase: booleanTrue if the i (ignoreCase) flag is set.
RegExp.multiline
ts
readonly multiline: booleanTrue if the m (multiline) flag is set; ^ and $ match line boundaries.
RegExp.source
ts
readonly source: stringThe pattern string.
RegExp.lastIndex
ts
lastIndex: intThe index at which the next match search begins (for global regexes). Advanced by exec and test when the g flag is set.
new RegExp()
ts
constructor(pattern: string, flags?: string)Create a new regular expression.
Parameters
pattern: The regex pattern string (e.g., "\d+").flags: Optional flags: "i" (ignoreCase), "g" (global), "m" (multiline), "s" (dotAll).
Throws: SyntaxError if the pattern is invalid.
RegExp.exec
ts
exec(input: string): anyExecute a search for a match. Returns a match object with properties 0–N (full match and capture groups), index (position in input), input (the original string), and length (1 + capture group count). Returns null if no match.
Parameters
input: The string to search in.
Returns: A match object or null.
RegExp.test
ts
test(input: string): booleanTest whether the pattern matches the string.
Parameters
input: The string to test.
Returns: true if a match was found, false otherwise.
RegExp.toString
ts
toString(): stringReturn the regex as a string in /pattern/flags format.
Returns: The regex string representation.
Generated from lang/types/builtin_regexp.d.tks in the ThicketScript repository.