/
replaceFirst

PhixFlow Help

replaceFirst

Function: replaceFirst()

Replace the first occurrence of a pattern with a replacement string.

Syntax

replaceFirst(listToCheck, findPattern, replacementString)

ArgumentTypeDescription
listToCheckArrayList of strings to evaluate
findPatternRegular ExpressionPattern to be matched in listToCheck
replacementStringStringString 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

Related content

replaceFirst
replaceFirst
More like this
replaceFirst
replaceFirst
More like this
replaceFirst
replaceFirst
More like this
replaceFirst
replaceFirst
More like this
replaceFirst
replaceFirst
More like this
replaceFirst
replaceFirst
More like this

Please let us know if we could improve this page feedback@phixflow.com