I want to change a Flowfile-Attribute with the UpdateAttribute Processor.
The Attribute "filename" is:
backup/int_backup/storage/teamname/toolname/path/bdsd9d83-dvvv8-41d9-a271-95b2284bd56c/20200420125822_11.zip
The beginning of the string shoult be cut and between teamname
and toolname
should be an other folder called archive
like:
teamname/archive/toolname/path/bdsd9d83-dvvv8-41d9-a271-95b2284bd56c/20200420125822_11.zip
I created a regex that identified the teamname:
/[^/]*/[^/]*/([^/]*)/
And a Regex that marks everythings after the third "/":
/[^/]*/[^/]*/[^/]*/([^*]*)
I tried to build up the string by adding:
${filename:replaceAll('/[^/]*/[^/]*/([^/]*)/', '$1')}/archive/${filename:replaceAll('/[^/]*/[^/]*/[^/]*/([^*]*)', '$1')
However, the result is not the regex result, it is the regex itself.
You may use
${filename:replaceAll('^(?:[^/]+/){3}([^/]+)(.*)', '$1/archive$2')}
See the regex demo
Details
^
- start of string (?:[^/]+/){3}
- three occurrences of 1+ chars other than /
and then a /
([^/]+)
- Group 1 ( $1
): one or more chars other than /
(.*)
- Group 2 ( $2
): the rest of the string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.