How to clean linebreak/carriage return from text

i am trying to parse something from html files, but some text in html has linebreak. So when i get text with xpath and write it csv lines writes different rows. How can i remove all line breaks after get text from xpath node.

2 Likes

Usually you should be able to replace linebreaks in Strings with a Regular Expression.

You can use the "String Replacer" Node for that.

  1. Select the String column to replace
  2. Use the Regular Expression Option.
  3. Enter \n in the field Pattern.
  4. Select the Replacement Text or just enter a single whitespace
  5. Select Option "all occurrences"

If the pattern \n does not work as expected you can also try [\r\n]+ which should work for all plattforms (Win/Mac/Linux).

2 Likes

It doesn’t work and my csv has few cells which has data in multiline so I trying to remove those next lines and put it as one cell back agian. But it doesn’t change anything.

1 Like

Hello Desh, noticed we are having a similar problem. However when I checked again, I found I was assuming the native checkboxes were in place, regular expression is not selected by default. Once I opened it again i realized i had not actually selected regular expression, and due to it being wildcard, it’s still successful. Hope this helps someone wondering if \n is working in the string replacer node.

Here’s the settings that will work.


3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.