Skip to main content
Solved

Insert a space between a number and text in a string


chris_m
Participant
Forum|alt.badge.img+1

I have some addresses that have been parsed fairly well. However I several thousand that have a letter after the house #, my geocoder requires a space here.

For example I have 123A Main Street I need 123 A Main Street

So I was thinking I could use the StringReplacer transformer to search for [0-9][A-Z], but I don't know what to put in the Replacement Text field.

Best answer by kd

Hi @chris_m

I would capture the house numbers and letters into two different capturing groups using ( ) in regex.

You can reference these afterwards in the replacement text field.

Your Text to match would thus become: ([0-9]+)([a-z])

and your replacement text: \\1 \\2

which basically translates to: (results of first capturing group) <space>(results of the second capturing group)

View original
Did this help you find an answer to your question?

2 replies

danilo_fme
Evangelist
Forum|alt.badge.img+41
  • Evangelist
  • April 12, 2018

Hi @chris_m,

I tested here in my Workspace with the transformer StringSearch:

Attached the template Workspace - workspace-stringsearch.fmwt

Thanks,

Danilo


Forum|alt.badge.img+1
  • Best Answer
  • April 12, 2018

Hi @chris_m

I would capture the house numbers and letters into two different capturing groups using ( ) in regex.

You can reference these afterwards in the replacement text field.

Your Text to match would thus become: ([0-9]+)([a-z])

and your replacement text: \\1 \\2

which basically translates to: (results of first capturing group) <space>(results of the second capturing group)


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