Skip to content

RegExp ​

Regular expressions.

Always available

No import needed. These names are in scope in every file.

RegExp class ​

ts
class RegExp

lastIndex advances after exec when the g flag is set, matching JS semantics.

RegExp.dotAll ​

ts
readonly dotAll: boolean

True if the s (dotAll) flag is set; . matches newlines.

RegExp.flags ​

ts
readonly flags: string

The flag string (e.g., "gi" for global and ignoreCase).

RegExp.global ​

ts
readonly global: boolean

True if the g (global) flag is set.

RegExp.ignoreCase ​

ts
readonly ignoreCase: boolean

True if the i (ignoreCase) flag is set.

RegExp.multiline ​

ts
readonly multiline: boolean

True if the m (multiline) flag is set; ^ and $ match line boundaries.

RegExp.source ​

ts
readonly source: string

The pattern string.

RegExp.lastIndex ​

ts
lastIndex: int

The 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): any

Execute 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): boolean

Test 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(): string

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