Capy-Bearer Documentation

regex_replace

host call

Capy

function regex_replace(pattern : string, replacement : string, subject : string, opt : any = {}) string

Description

Use $1 for a numbered capture in replacement. opt.flags takes the flag letters described for regex_match().

Parameters

pattern : regular expression

replacement : replacement text

subject : source text

opt : options map with flags

Return Values

Text with all matches replaced.

Example

Capy

print(regex_replace("([a-z]+)", "<$1>", "capy docs"), "\n")

Output

<capy> <docs>