Skip to main content
Question

Remove carriage return / line feeds

  • March 24, 2015
  • 5 replies
  • 1107 views

Forum|alt.badge.img
Dear FME community,

 

 

I have a single column wich contains carriage returns or line feeds. Is there a way to remove these signs, for example with the StringReplacer? Can anybody please help with the correct term in "Text to match".

 

 

I have three signs I want to replace with nothing (i.e. remove them):

 

- carriage returns / line feeds

 

- semicolons

 

- dollar signs

 

 

Kind regards

 

Thomas

 

 
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

owen
Forum|alt.badge.img+1
  • March 24, 2015
Hi Thomas, 

 

 

You can use \\n to search for carriage returns.

 

 

Owen

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • March 24, 2015
y0u can also use hexadecimal approach.

 

 

carriage return \\x0D and linefeed \\x0A etc.

 

 

Forum|alt.badge.img
  • Author
  • March 25, 2015
Many thanks Owen and Gio! The StringSearcher with [\\r\\n\\$,;] works perfectly. Problem solved :)

 

 

Kind regards

 

Thomas

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • March 27, 2015
Dollarsign, carriagereturn and linefeeds must be escaped with a "\\".

 

should be:

 

 

Dollarsign must be escaped with a "\\".

 

carriagereturn and linefeeds: non-printable characters shorthands are (amongst others)

 

\\t matches a tab character , \\r a carriage return and \\n a linefeed

 

 

"\\r" is a carriage return.

 

"\\xFF" is non-Unicode. "uFFFF" is unicode. (where F s a hexadecimal character)

 

 

in "x0D" the "0D" is the ascii code for carriage return in hexadecimal etc.

 

 

 

Hope this satisfies the disgruntlled... ;)

 

 

If you don't believe me, look it up on any regexp info site (of wich there are zillions).

 

 

 

tim_wood
Contributor
Forum|alt.badge.img+8
  • Contributor
  • March 24, 2017

I used a TestFilter to examine some CSV data I have where one field contains Carriage Returns and/or Line Feeds. I created separate Output Ports for "Contains RegEx \\r" and "Contains RegEx \\n" which revealed that I had BOTH types in the data. Therefore I need to replace both. So in StringReplacer my Mode is "Replace Regular Expression" and my "Text To Replace" is (\\r|\\n).

Out of 330,000 features, only 73,000 contained CR and/or LF. However, it is 9 seconds quicker to JUST use StringReplacer versus Tester and StringReplacer where the Tester is only sending features to StringReplacer that need fixing.