Skip to content

$replaceTextWithRegex

$replaceTextWithRegex will replace specific segments of text.

Usage

$replaceTextWithRegex[text;reg;flags;newText]

Parameters

FieldTypeDescriptionRequired
textstringText you want to modify.true
regstringThe regex that will be replaced.true
flagsstringFlags.true
newTextstringThe text that will replace reg.false

Flags

Flags
gReplace all matches (case-sensitive)
mMultiline matching
iReplace all matches (case-insensitive)

Example(s)

This will replace more with less:

1
client.command({
2
name: "replaceTextWithRegex",
3
code: `
4
$replaceTextWithRegex[This function is more complicated than it looks.;more;g;less]
5
`
6
});

Advanced Example

This will replace less with more:

1
client.command({
2
name: "replaceTextWithRegex",
3
code: `
4
$replaceTextWithRegex[This function is more simple than it looks.;complicated;g;simple]
5
`
6
});