API Reference
Classes
Regex
- Implements: ILiftable
Represents a compiled regular expression pattern.
Methods
Name | Description |
---|---|
| Finds the first occurrence of the pattern within the text. |
| Finds all non-overlapping occurrences of the pattern within the text. |
| Finds the start and end index of all matches within the text. |
| Finds the start and end index of the first match within the text. |
| Finds the first match and its submatches. |
| Finds the start and end index of the match and all submatches. |
| Replaces all occurrences of the match with a replacement string. |
| Checks if the regular expression matches the provided text. |
find
find(text: str): str?
Finds the first occurrence of the pattern within the text.
text
Required
- 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.
text
Required
- 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.
text
Required
- 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.
text
Required
- Type: str
The text to search within.
findSubmatch
findSubmatch(text: str): MutArray<str>?
Finds the first match and its submatches.
text
Required
- 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.
text
Required
- Type: str
The text to search within.
replaceAll
replaceAll(text: str, replacement: str): str
Replaces all occurrences of the match with a replacement string.
text
Required
- Type: str
The text to search and replace within.
replacement
Required
- Type: str
The replacement string.
test
test(text: str): bool
Checks if the regular expression matches the provided text.
text
Required
- Type: str
The text to check against.
Static Functions
Name | Description |
---|---|
| Compiles the provided regex pattern into a Regex object. |
compile
regex.compile(pattern: str);
Compiles the provided regex pattern into a Regex
object.
pattern
Required
- Type: str
The regex pattern to compile.