Regex ReplaceAll() Method

Replaces matches in a compiled regex.

Function Signature

 ReplaceAll( value, replacement )

Parameters

Parameter Type Description

value

string

The string to be searched.

replacement

string

Replaces each matched value.

Return

Type Description

string

A string where all matches for the compiled Regex in "value" are replaced with "replacement".

Technical Details

SBM ModScript version: 11.3.

Example

var r = Regex(); // Regex object 'r'
r.Compile("\\d+"); // Compile regex expression "\d+"
var changed = r.ReplaceAll("12ab3d456e78", "ABC"); 
// Replace each group of digits in the first string "value" with the replacement string
Ext.WriteStream( changed );  

Result:

ABCabABCdABCeABC

Notes

None.

Related Topics

Regex