Specification change of String#replaceAll() in Script Task (Ver. 14.1)
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).
https://support.questetra.com/versions/version-141/
The behavior specification of String#replaceAll() method is changed
Until Ver. 14.0, it worked as a method of java.lang.String, but after Ver. 14.1, it works as a method of JavaScript String
Changed due to the availability of replaceAll() in JavaScript Strings as of EcmaScript 2021
java.lang.String#replaceAll()
↓
JavaScript String#replaceAll()
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll
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.
TypeError
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.
Comments
0 comments