Question

Remove newline space

  • 27 March 2019
  • 6 replies
  • 149 views

Badge +1

Hi all,

In the attribute of my data, there is sometimes newlines and I want to trim them. I am using the AttributeTrimmer however it is not working.

The data looks like this:

{33}SCHOOL, BUS ONLY 8-10AM 12-4PM EXC SAT-SUN-HOL SEPT

 

 

THRU JUNE,

I want to trim it like this:

{33}SCHOOL, BUS ONLY 8-10AM 12-4PM EXC SAT-SUN-HOL SEPT THRU JUNE,

 

Is my setting not correct?

Best


6 replies

Userlevel 4

You'll need to use the StringReplacer for this.

The AttributeTrimmer only checks the start and end of the attribute value, so the newline embedded somewhere in the middle won't be removed.

Badge +1

You'll need to use the StringReplacer for this.

The AttributeTrimmer only checks the start and end of the attribute value, so the newline embedded somewhere in the middle won't be removed.

What should be the text to replace? I tried \\n and it did not work out.

Badge +1

You'll need to use the StringReplacer for this.

The AttributeTrimmer only checks the start and end of the attribute value, so the newline embedded somewhere in the middle won't be removed.

Thank you! It worked with /v :)

Userlevel 4

Thank you! It worked with /v :)

Excellent. You can also simply open the Text Editor window and manually enter a newline on its own.

Excellent. You can also simply open the Text Editor window and manually enter a newline on its own.

So I didn't scroll down to this response and was tearing my hair out for 10 minutes trying /v \\r\\n \\n etc.

 

I eventually found https://knowledge.safe.com/questions/48695/how-to-split-a-delimited-string-with-a-carriage-re.html which is a related issue where the answers there were the same as you gave here.

Obvious only in hindsight, as I never would have expected I would need to go into the text editor than just use the text box provided in the StringReplacer

Badge

Thank you! It worked with /v :)

Just a tip for anybody who is trying to split a multiline text attribute using an AttributeSplitter:

  1. Use the text Editor to specify the newline: type <enter so your first line is empty, then close the text editor. So obvious one might overlook this option.
  2. Expose the list attribute list that is created after the AttributeSplitter image

Reply