Solved

Insert a space between a number and text in a string

  • 12 April 2018
  • 2 replies
  • 28 views

Badge +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.

icon

Best answer by kd 12 April 2018, 22:12

View original

2 replies

Userlevel 4
Badge +30

Hi @chris_m,

I tested here in my Workspace with the transformer StringSearch:

Attached the template Workspace - workspace-stringsearch.fmwt

Thanks,

Danilo

Badge +1

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