Skip to main content
Solved

combine text values with the stringconcatenator and ignore emtpy values

  • September 5, 2024
  • 2 replies
  • 95 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)
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

dustin
Influencer
Forum|alt.badge.img+31
  • 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  !