replaceFirst()
The strLib.replaceFirst()system function replaces the first substring of the string that matches the given regular expression with the given replacement string.
Syntax
strLib.replaceAll(
target STRING | CHAR | DBCHAR | MBCHAR | UNICODE In,
toReplace STRING | CHAR | DBCHAR | MBCHAR | UNICODE In)
replacement STRING | CHAR | DBCHAR | MBCHAR | UNICODE In)
returns (result STRING | CHAR | DBCHAR | MBCHAR | UNICODE))
- target
-
Input can be any value that is assignment compatible with any of the above types.
- toReplace
-
Input can be any value that is assignment compatible with any of the above types. toReplace is the regular expression pattern to be replaced.
- replacement
-
Input can be any value that is assignment compatible with any of the above types.
- result
-
It returns a new string composed of the target string where all the occurrences matching the regular expression are replaced.
Example
function main()
myStr String = “Customer department service”;
sysLib.writeStdout(“Replaced string is: “+ strLib.replaceSubStr(myStr, “department”, “support”));
end
The output is as follows:
Replaced string is: Customer support service