Skip to main content
Solved

String Replacer - Replace consecutive spaces with single space

  • October 2, 2014
  • 3 replies
  • 173 views

Hello!

 

I have several fields in a file that contain consecutive spaces. I want to replace the consecutive spaces (generally just 2) with one single space. But I've tried several ways with String Replacer to denote 2 spaces and I can't seem to figure it out. Can anyone help?

 

 

Example:

 

What I have:

 

123  Main  Street

 

What I want:

 

123 Main Street

Best answer by takashi

Hi,

 

 

You are on the right track - StringReplacer. Try this setting to the parameters.

 

-----

 

Text to Match: \\s{2,}

 

Replacement Text:  <invisible, but enter a white space here>

 

Use Regular Expressions: yes

 

-----

 

 

The expression matches with "two or more consecutive white spaces".

 

See also these links to learn more about regular expressions.

 

- FME Workbench Help: Regular Expressions (http://docs.safe.com/fme/html/FME_Workbench/Default.htm#Regular_Expressions.htm)

 

- Regular-Expressions.info (http://www.regular-expressions.info/)

 

 

Takashi
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.

3 replies

takashi
Celebrity
  • Best Answer
  • October 2, 2014
Hi,

 

 

You are on the right track - StringReplacer. Try this setting to the parameters.

 

-----

 

Text to Match: \\s{2,}

 

Replacement Text:  <invisible, but enter a white space here>

 

Use Regular Expressions: yes

 

-----

 

 

The expression matches with "two or more consecutive white spaces".

 

See also these links to learn more about regular expressions.

 

- FME Workbench Help: Regular Expressions (http://docs.safe.com/fme/html/FME_Workbench/Default.htm#Regular_Expressions.htm)

 

- Regular-Expressions.info (http://www.regular-expressions.info/)

 

 

Takashi

  • Author
  • October 3, 2014
Got it. Thanks so much!!

tim_wood
Contributor
Forum|alt.badge.img+8
  • Contributor
  • November 2, 2017