Docs
API Reference
Regex

Regular Expression

ℹ️
Page is being worked on.

Functions

  1. new

Classes

  1. Regex

Functions

new

regex.new(pattern: string, flags: string?): Regex
️⚠️
Can Error

Compiles a regular expression pattern.

Flags:

  • i: Case insensitive
  • m: 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

  1. match
  2. search
  3. format
  4. isMatch
  5. replace
  6. replaceAll
  7. captures

Regex.match

regex.Regex:match(str: string): {RegexMatch}?
️⚠️
Can Error

Match a string

Parameters
  • str: string - The string to match.
Returns
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
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): boolean

Check 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
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;
}