Skip to main content
Question

Remove carriage return / line feeds


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

 

 

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.


Reply


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