In Ver. 14.1 updated in August-September 2022, the operating specifications of the String#replaceAll() method have been changed in Script Task/Service Task (Add-on).
The behavior specification of String#replaceAll() method is changed
The replaceAll() method returns a new string with all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match. The original string is left unchanged.
Thrown if the pattern is a regex that does not have the global (g) flag set (its flags property does not contain "g").
With this change, for example, if you want to replace "number" with "*", please rewrite it as follows.(The first argument pattern is specified by RegExp with global flags)
let text = "a0123456789a".replaceAll("[0-9]", "*");
let text = "a0123456789a".replaceAll(/[0-9]/g, "*");
Please sign in to leave a comment.