Link Search Menu Expand Document

RegexMatcher.AppendReplacement Method

Explanation Performs continuous append and replacement.

Returns the character string from the input character string after the append position to the previously matched part. At this time, the matched part is replaced with the replacement character string. The append position then moves to the next position in the trailing index of the match.
Call format var s = rm.AppendReplacement( replacement )
Return value From the input character string after the append position to the part that matched last time, the match part is replaced with the replacement character string and returned.
From Ver.5.0.1, UString type character string is returned in Unicode mode.
Arguments String replacement Replacement string
You can use a reference to a forward reference group by "$ n"
From Ver.5.0.1, it is treated as UString type in Unicode mode.
Exception Func 4 The argument value is invalid
Func 14 The value cannot be referenced
Example of use
var p = RegexPattern.Compile("([0-9])([0-9])([0-9])");
var m = p.Matcher("Biz/Browser 311, Biz/Desginer 400, abcde");
var s = "";
while (m.Find()) {
    s += m.AppendReplacement("$1.$2.$3");
}
s += m.AppendTail();
print(s, "\n");
    
Related item AppendTail method