Regular Expression
ℹ️
Page is being worked on.
Functions
Classes
Functions
new
regex.new(pattern: string, flags: string?): Regex️⚠️
Can Error
Compiles a regular expression pattern.
Flags:
i: Case insensitivem: Multiline
Parameters
pattern: string- The pattern to compile.
Returns
Regex- The compiled regular expression.
Throws
- If the pattern is invalid, an error will be thrown.
Classes
Regex
Functions
Regex.match
regex.Regex:match(str: string): {RegexMatch}?️⚠️
Can Error
Match a string
Parameters
str: string- The string to match.
Returns
{RegexMatch}?- The match result.
Throws
- If out of memory, an error will be thrown.
Regex.search
regex.Regex:search(str: string): {RegexMatch}?️⚠️
Can Error
Search a string
Parameters
str: string- The string to search.
Returns
{RegexMatch}?- The search result.
Throws
- If out of memory, an error will be thrown.
Regex.format
regex.Regex:format(str: string, format: string): string️⚠️
Can Error
Format a string
Parameters
str: string- The string to format.
Returns
string- The formatted string.
Throws
- If out of memory, an error will be thrown.
Regex.isMatch
regex.Regex:isMatch(str: string): booleanCheck if a string matches
Parameters
str: string- The string to check.
Returns
boolean- If the string matches.
Regex.replace
regex.Regex:replace(str: string, replacement: string): string️⚠️
Can Error
Replace the first occurrence of a string
Parameters
str: string- The string to replace.replacement: string- The replacement string.
Returns
string- The replaced string.
Throws
- If out of memory, an error will be thrown.
Regex.replaceAll
regex.Regex:replaceAll(str: string, replacement: string): string️⚠️
Can Error
Replace all occurrences of a string
Parameters
str: string- The string to replace.replacement: string- The replacement string.
Returns
string- The replaced string.
Throws
- If out of memory, an error will be thrown.
Regex.captures
regex.Regex:captures(str: string, global: boolean?): {{RegexMatch}}️⚠️
Can Error
Capture all occurrences of a string
Parameters
str: string- The string to capture.global: boolean?- The flags to use.
Returns
{{RegexMatch}}- The captured strings.
Throws
- If regex search fails, an error will be thrown.
Types
RegexMatch
export type RegexMatch = {
--[[
The captured group.
]]
string : string;
--[[
The index of the group.
]]
index : number;
}Last updated on