Regex module

replace_n

procedure · 2 overloadsSource

Replaces the first limit matches (all of them when limit < 0).

replace_n :: (
    re: *Regex,
    text: string,
    replacement: string,
    limit: int
) -> string

Replaces the first limit matches (all of them when limit < 0).

Parameters

re: *Regex
text: string
replacement: string
the new text; $1 or ${1} stands for a group and $name or ${name} for a named one.
limit: int
how many matches to replace. Negative replaces all of them.

Returns

string
replace_n :: ($R: Type, text: string, replacement: string, limit: int) -> string

Parameters

$R: Type
text: string
replacement: string
limit: int

Returns

string

See also