Created 01-24-2018 02:42 PM
I have requirement where I need to append and prepend the attribute with "$$$". how ever, Nifi expression language is appending or prepending with "\$"
For example: if attribute named "myattr" value is "This is Test"
when I do ${myattr:prepend('$$$'):append('$$$')}
I am expecting "$$$This is Test$$$"
but the output is "\$This is Test\$"
Is there any way to append or prepend the attribute with "$$$"
Created 01-24-2018 02:59 PM
use 9$ instead of 3$
${myattr:prepend('$$$$$$$$$'):append('$$$$$$$$$')}
in expression language if you use 3$ are results as 1$ so we need to use 9$ if you want 3$ sign to be added to the attribute value.
Input:- "myattr" value is "This is Test"
expression:- ${myattr:prepend('$$$$$$$$$'):append('$$$$$$$$$')}
Output:- $$$This is Test$$$
Created 10-31-2024 06:07 AM
@SS_Jin
Another option is to use the NiFi expression Language (NEL) function "literal()}" in the NEL statement:
${myattr:append(${literal('$$$')}):prepend(${literal('$$$')})}
This removes the need to you are using the correct number of "$" to escape $ in the NEL.
Please help our community grow. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.
Thank you,
Matt
Created 01-24-2018 02:59 PM
use 9$ instead of 3$
${myattr:prepend('$$$$$$$$$'):append('$$$$$$$$$')}
in expression language if you use 3$ are results as 1$ so we need to use 9$ if you want 3$ sign to be added to the attribute value.
Input:- "myattr" value is "This is Test"
expression:- ${myattr:prepend('$$$$$$$$$'):append('$$$$$$$$$')}
Output:- $$$This is Test$$$
Created 01-24-2018 06:06 PM
what might be the reason for the extra character '\' ?
Created 01-24-2018 06:24 PM
it seems like replaceText processor is replacing '$$$$$*' in the content to '\$' while replacing the flow file content!
seems like actual issue is I have an attribute namely "myattr"
when myattr is "$$This is test$$", if I replace the flowfile content with myattr, the content in the flowfile is "\$this is test\$"
Created 10-31-2024 01:59 AM
Thanks, prepend worked for me, I needed to add a comma before a value.
Created 10-31-2024 06:07 AM
@SS_Jin
Another option is to use the NiFi expression Language (NEL) function "literal()}" in the NEL statement:
${myattr:append(${literal('$$$')}):prepend(${literal('$$$')})}
This removes the need to you are using the correct number of "$" to escape $ in the NEL.
Please help our community grow. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.
Thank you,
Matt
Created 10-31-2024 06:17 AM
That's perfect !