Skip to main content
Question

Remove newline space


jugoslaviaa
Enthusiast
Forum|alt.badge.img+6

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

david_r
Celebrity
  • March 27, 2019

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.


jugoslaviaa
Enthusiast
Forum|alt.badge.img+6
  • Author
  • Enthusiast
  • March 27, 2019
david_r wrote:

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.


jugoslaviaa
Enthusiast
Forum|alt.badge.img+6
  • Author
  • Enthusiast
  • March 27, 2019
david_r wrote:

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 :)


david_r
Celebrity
  • March 27, 2019
jugoslaviaa wrote:

Thank you! It worked with /v :)

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


nmartin
Participant
  • Participant
  • June 18, 2020
david_r wrote:

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


r_huesken
Contributor
Forum|alt.badge.img+5
  • Contributor
  • March 2, 2023
jugoslaviaa wrote:

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

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings