Skip to main content
Solved

combine text values with the stringconcatenator and ignore emtpy values

  • September 5, 2024
  • 2 replies
  • 56 views

maisels
Contributor
Forum|alt.badge.img+3

Hello, i have a problem with the stringconcatenator. i would like to combine several values of text attributes with the stringconcatenator as a new attribute. the values should be separated by a comma, empty attributes should be ignored and there must be no comma at the end. how can this be achieved? I always get two or more comms if the attribute is emtpy. Thanks a lot.

Best answer by dustin

You can follow the StringConcatentor with two StringReplacers:

One using the following regex, replacing with a single comma.

,{2,}

The second StringReplacer will replace any remaining comma at the end with blank string using

,$

 

Alternatively, you can do this in a single AttributeCreator using the following string:

@ReplaceRegularExpression(@ReplaceRegularExpression(@Value(att),",{2,}",",",caseSensitive=TRUE),",$","",caseSensitive=TRUE)
View original
Did this help you find an answer to your question?

2 replies

dustin
Influencer
Forum|alt.badge.img+30
  • Influencer
  • Best Answer
  • September 5, 2024

You can follow the StringConcatentor with two StringReplacers:

One using the following regex, replacing with a single comma.

,{2,}

The second StringReplacer will replace any remaining comma at the end with blank string using

,$

 

Alternatively, you can do this in a single AttributeCreator using the following string:

@ReplaceRegularExpression(@ReplaceRegularExpression(@Value(att),",{2,}",",",caseSensitive=TRUE),",$","",caseSensitive=TRUE)

maisels
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • September 6, 2024

Perfect, that works great for me. 😃

Thanks  !


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