Yuari
Documentation
Docs/Regex/Regex:Replace

Regex:Replace

Returns text with the first regex match replaced.

Syntax

Regex:Replace(text: string, replacement: string) -> string

Parameters

ParameterTypeDescription
textstringThe text value to process.
replacementstringThe replacement value used by the call.

Returns

TypeDescription
stringText with the first regex match replaced

Description

Regex:Replace 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.

The change is applied directly to the live target, so later reads observe the updated value.

Example

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

Notes

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