Skip to Content
Skip to Content
ClassesRegex

Regex


Methods

match

:match(input: string | buffer): {export type RegexMatch = { string: string, index: number, }RegexMatchexport type RegexMatch = { string: string, index: number, }}?

Parameters

  • input: string | buffer - The input to match against the regex.

Throws

  • Regex Error
  • Memory Error
:search(input: string | buffer): {export type RegexMatch = { string: string, index: number, }RegexMatchexport type RegexMatch = { string: string, index: number, }}?

Parameters

  • input: string | buffer

Throws

  • Regex Error
  • Memory Error

captures

:captures(input: string | buffer, global: boolean?): {{export type RegexMatch = { string: string, index: number, }RegexMatchexport type RegexMatch = { string: string, index: number, }}}

Parameters

  • input: string | buffer
  • global: boolean? - If true, the function will return all captures instead of just the first
    • default: false

Throws

  • Regex Error
  • Memory Error

split

:split(input: string | buffer, global: boolean?): {string}

Parameters

  • input: string | buffer - The input to split against the regex.
  • global: boolean? - If true, the function will return all splits instead of just the first
    • default: false

Throws

  • Regex Error
  • Memory Error

isMatch

Returns if a string matches the pattern.

:isMatch(input: string | buffer): boolean

Parameters

  • input: string | buffer

Throws

  • Regex Error

format

Format a string.

:format(str: string, format: string): string

Parameters

  • str: string - The string to replace.
  • format: string

Throws

  • Regex Error
  • Memory Error

replace

Replace the first occurrence of a string.

:replace(str: string, replacement: string): string

Parameters

  • str: string - The string to replace.
  • replacement: string - The replacement string.

Throws

  • Regex Error
  • Memory Error

replaceAll

Replace all occurrences of a string.

:replaceAll(str: string, replacement: string): string

Parameters

  • str: string - The string to replace.
  • replacement: string - The replacement string.

Throws

  • Regex Error
  • Memory Error
Last updated on