Support Questions

Find answers, ask questions, and share your expertise

Replace Line Feed character in Nifi

avatar

I have a line feed LF character in my csv file that I would like to replace with a pipe character |. ASCII value for LF is 10

How can i do that using replace text processor.

1 ACCEPTED SOLUTION

avatar
Master Guru

You should be able to use line-by-line as the Evaluation Mode in the ReplaceText processor, using \n or \\n (the slash may need to be escaped, e.g.) as the match value and | or \| as the replace value (again, the latter if it needs to be escaped to be proper regex for the pipe character).

View solution in original post

3 REPLIES 3

avatar
Master Guru

You should be able to use line-by-line as the Evaluation Mode in the ReplaceText processor, using \n or \\n (the slash may need to be escaped, e.g.) as the match value and | or \| as the replace value (again, the latter if it needs to be escaped to be proper regex for the pipe character).

avatar

Thanks Matt. that worked. I was curious why it does not work with the "Entire Text" evaluation mode.

avatar

Hi @Matt Burgess

I want to do something like this ${'$1':escapeJson()} as replacement value in replaceText processor
search value being (?s)(^.*$)
evaluation mode line-by-line

bt this is not working as expected.
can you please help if i need to replace each line of file with jsonescaped content