Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you replace part of a string of an apache NIFI attribute?

Can you update attribute using replace text of an attribute's value?

I have an attribute - ${a} which has a place holder called "PLACEHOLDER". How do I replace each occurrence of the word "PLACEHOLDER" in attribute ${a} with the value of attribute ${b}?

I have tried using replace text processor - using both Regex Replace and Literal Replace replacement strategies without any luck. See below my example. 1. Generate flow file. Generate Flowfile

  1. Replace text attempt 1 - literal replace strategy enter image description here

  2. Replace text attempt 2 - regex replace strategy enter image description here

None works as attribute value is unchanged.

enter image description here

How can I achieve this? If not this processor, which one please? How? Thanks in advance!

like image 636
zamentali Avatar asked Jan 03 '23 06:01

zamentali


1 Answers

Haha...Such a bummer. Found the answer. Should have kept digging through the documentation i guess. Use update attribute processor then set attribute to ${a:replace('PLACEHOLDER', ${b})} Hope this helps someone who's not searched documentation properly like me in future :-)

like image 171
zamentali Avatar answered Jan 26 '23 20:01

zamentali