Search code examples
regexapache-nifi

How to remove blank spaces in line with regex?


I have file like below.,

 23,1:30 - 2:00,10,,,,

 23,1:30 - 2:00,600,,,,

   23,1:30 - 2:00,600,,,,
23,1:2 - 23:00,321,,,,

Now i need to remove the blank spaces in whole file and replace it with empty.

I have already tried with This regex for search \ s+ and replace with \n it doesn't work

So i have need search and replacement value for find blank spaces and replace it with empty like below output.

23,1:30 - 2:00,10,,,,
23,1:30 - 2:00,600,,,,
23,1:30 - 2:00,600,,,,
23,1:2 - 23:00,321,,,,

And finally need search and replacement value for ReplaceText processor which perform my requirements.


Solution

  • You can try something like this :

    regex search >>  \n+\s+
    replace with >>  \n
    

    see demo