CenterView Help
replaceFirst
Function: replaceFirst()
Replace the first occurrence of a pattern with a replacement string.
Syntax
replaceFirst(listToCheck, findPattern, replacementString)
Argument | Type | Description |
---|---|---|
listToCheck | Array | List of strings to evaluate |
findPattern | Regular Expression | Pattern to be matched in listToCheck |
replacementString | String | String to replace matching pattern in list |
Examples
replaceFirst(in.fileName, "[0-9]{8}", "")
replaceFirst() removes the first string of 8 digits from file names contained in the attribute in.fileName.
If in.fileName = "20060712file-proc20070103-1263", this returns "file-proc20070103-1263".
replaceFirst(in.fileName, "file_([0-9A-Za-z]+)\\.txt", "$1")
replaceFirst() matches alphanumeric characters between "file_" and ".txt", and replaces the whole string with this value, if a match is made. In this way, a part or parts of the input string can be extracted. If in.fileName = "file_teamA.txt", the result of this expression will be "teamA".
See Also
Please let us know if we could improve this page feedback@phixflow.com