Skip to main content

API Reference

Classes ​

Regex ​

Represents a compiled regular expression pattern.

Methods ​

NameDescription
find
Finds the first occurrence of the pattern within the text.
findAll
Finds all non-overlapping occurrences of the pattern within the text.
findAllIndex
Finds the start and end index of all matches within the text.
findIndex
Finds the start and end index of the first match within the text.
findSubmatch
Finds the first match and its submatches.
findSubmatchIndex
Finds the start and end index of the match and all submatches.
replaceAll
Replaces all occurrences of the match with a replacement string.
test
Checks if the regular expression matches the provided text.

find ​
find(text: str): str?

Finds the first occurrence of the pattern within the text.

textRequired ​
  • Type: str

The text to search within.


findAll ​
findAll(text: str): MutArray<str>

Finds all non-overlapping occurrences of the pattern within the text.

Returns an empty array if no matches are found.

textRequired ​
  • Type: str

The text to search within.


findAllIndex ​
findAllIndex(text: str): MutArray<MutArray<num>>

Finds the start and end index of all matches within the text.

Indices are zero-based.

textRequired ​
  • Type: str

The text to search within.


findIndex ​
findIndex(text: str): MutArray<num>?

Finds the start and end index of the first match within the text.

textRequired ​
  • Type: str

The text to search within.


findSubmatch ​
findSubmatch(text: str): MutArray<str>?

Finds the first match and its submatches.

textRequired ​
  • Type: str

The text to search within.


findSubmatchIndex ​
findSubmatchIndex(text: str): MutArray<MutArray<num>>?

Finds the start and end index of the match and all submatches.

textRequired ​
  • Type: str

The text to search within.


replaceAll ​
replaceAll(text: str, replacement: str): str

Replaces all occurrences of the match with a replacement string.

textRequired ​
  • Type: str

The text to search and replace within.


replacementRequired ​
  • Type: str

The replacement string.


test ​
test(text: str): bool

Checks if the regular expression matches the provided text.

textRequired ​
  • Type: str

The text to check against.


Static Functions ​

NameDescription
compile
Compiles the provided regex pattern into a Regex object.

compile ​
regex.compile(pattern: str);

Compiles the provided regex pattern into a Regex object.

patternRequired ​
  • Type: str

The regex pattern to compile.