String Replacement Methods (NFS 65528, JEDI 2)

The String primitive type now provides the replace__ and replaceFrom__ methods, which have the following signatures.

replace__(target: String; replacement: String; bIgnoreCase: Boolean): String;
replaceFrom__(target: String; replacement: String; startIndex: Integer; bIgnoreCase: Boolean): String;

Both methods return a new string that has had the specified replacement made. The receiver string has the substring specified in the target parameter replaced by the substring specified in the replacement parameter. The replace__ method replaces all occurrences; the replaceFrom__ method replaces only the first occurrence starting from the specified startIndex parameter.

The replaceFrom__ method raises exception 1413 (Index used in string operation is out of bounds) if the value specified in the startIndex parameter is less than 1 or it is greater than the length of the original string. Both methods raise exception 1002 (Invalid parameter value) if the value specified in the target parameter has a length of zero (0).

In JADE 2016.0.02 (Service Pack 1), these methods were implemented as stringReplace and stringReplaceFrom external methods in the RootSchema jomsupp system library. As these methods were provided in a service pack, they were not defined in the String primitive type in the RootSchema, to prevent name conflicts.

The new String primitive type methods will conflict with any existing String method named replace__ or replaceFrom__ defined in an earlier release.