Question

How to remove many blank spaces in a field so only one blank space remains?

  • 30 March 2016
  • 3 replies
  • 24 views

Badge

Dear FME community,

I have an attribute which has many blank spaces in the middle. I want to reduce the amount of blank spaces to only one single space (character). I'm not very fit in regular expression, so I'm hoping somebody can tell me the code for the StringReplacer. Many thanks!

Kind regards

Thomas


3 replies

Userlevel 2
Badge +12

I managed to do this using a sequence of 2 StringReplacer transformers:

The first using regular expressions replacing \\s* by #, the second not using regular expressions replacing ## by a white space.

Badge

Hi @thomask

one more option is a single StringReplacer with regular expression. The StringReplacer parameters should be:

  • Text to Match: [<space>]+
  • Replacement Text: <space>
  • Use Regular Expressions: yes
Badge +9

Just a slight update based on FME 2019

Reply