Skip to main content
Solved

String Replacer - Replace consecutive spaces with single space

  • October 2, 2014
  • 3 replies
  • 119 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
View original
Did this help you find an answer to your question?

3 replies

takashi
Influencer
  • 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

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