Created on 11-09-2017 04:11 PM - edited 08-18-2019 12:04 AM
Hi All,
Thanks a lot to this awesome community.
I am observing a new line is added in the beginning after replacing a text. but when observed through nifi ui I do not see the new line in the beginning.
I reffered this link
https://community.hortonworks.com/questions/147226/replacetextprocessor-remove-blank-lines.html
Any suggestion
Thanks Dheeru
Created 11-09-2017 05:23 PM
Can you once check your replace text processor configurations
if the Replacement Strategy property as Prepend that means you are adding new line at starting of the file.
As that new line won't show in NiFi UI but when you do cat on the file then only it shows the new line.
Created 11-09-2017 05:23 PM
Can you once check your replace text processor configurations
if the Replacement Strategy property as Prepend that means you are adding new line at starting of the file.
As that new line won't show in NiFi UI but when you do cat on the file then only it shows the new line.
Created on 11-09-2017 05:32 PM - edited 08-18-2019 12:03 AM
@Shu Thanks for the response I appreciate it. No I am not using Prepend strategy I am using regex replace all attached is the image
Created on 11-09-2017 06:51 PM - edited 08-18-2019 12:03 AM
If your file having any new line as first line of your file that would won't show in NiFi UI.
you need to use another replace text processor following with the existing replace text processor
Search value property as
(\s$|^\s*)(.*) //match if you are having any new lines in starting and ending position of the file
Replacement value property as $2
Why existing replace text won't match empty lines?
As you are having replace text processor with
\n+\s //matches for only empty lines in between the text but not first
If you have empty lines in between the text then you are going to replace them with shift+enter.
But in this case you are having empty line at starting of the file then you need to take off them,that's the reason why you need to use another replace text processor.
Flow:-
First replace text processor //is going to replace empty lines in text with shift+enter.<br>second replace text processor //replace empty lines at first and end lines in text then remove them from file
Created 11-09-2017 07:20 PM
@Shu thanks for the response will try and get back to you, appreciate it
Created 11-09-2017 07:40 PM
@Shu I checked again, the regex \n+\s+ does not remove the first line if it is blank, other than that it replaces all the blank lines, even if there are empty lines in the end, trying your regex for removing first blank line Thanks again