Skip to main content
Solved

replace last comma with &

  • May 13, 2024
  • 1 reply
  • 56 views

nicholas
Contributor
Forum|alt.badge.img+14

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?

Best answer by geomancer

Sure, this is called a 'Negative lookahead’.

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

 

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

1 reply

geomancer
Evangelist
Forum|alt.badge.img+51
  • Evangelist
  • Best Answer
  • May 13, 2024

Sure, this is called a 'Negative lookahead’.

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

 


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