Yuari
Documentation
Docs/Regex/Regex.new

Regex.new

Compiles a regex object with Match, MatchMany and Replace.

Syntax

Regex.new(pattern: string, flags?: string) -> nil

Parameters

ParameterTypeDescription
patternstringThe pattern value used by the call.
flags?stringThe flags value used by the call.

Returns

TypeDescription
nilThis function does not return a value.

Description

Regex.new is part of the Regex library. Regex wraps a compiled pattern object. Matching and replacement follow the module's regex engine rather than Lua patterns.

Each call creates or returns a fresh object or value that you can store and pass to other functions.

Example

local re = Regex.new("(%a+)")
print(re:Match("hello 123"))

Notes

  • Regex patterns use the module's engine; refer to its flag syntax rather than Lua patterns.