Skip to main content
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
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
Got it. Thanks so much!!

See also:

https://knowledge.safe.com/questions/25193/how-to-remove-many-blank-spaces-in-a-field-so-only.html


Reply