Skip to main content

I have an attribute containing String values such as

Gladstone Regional

Southern Downs Regional, Goondiwindi Regional

Moreton Bay City, Noosa Shire, Somerset Regional, Sunshine Coast Regional

I want to replace the last comma with “ &” so that the output will look like this

Gladstone Regional

Southern Downs Regional & Goondiwindi Regional

Moreton Bay City, Noosa Shire, Somerset Regional & Sunshine Coast Regional

Is there a way to use a Regular Expression inside the StringReplacer transformer to accomplish this?

Sure, this is called a 'Negative lookahead’.

In your case: ,(?!.*,) will do the trick.

 


Reply