Skip to main content
Question

String Replacer with Conditional Value

  • October 24, 2017
  • 2 replies
  • 206 views

pflegpet
Contributor
Forum|alt.badge.img+8

Hi! I'm trying to create a conditional value for a StringReplacer but I don't get it to work. Basically I have an attribute that can contain substrings starting with a space followed by a slash (e.g. "keep / remove"). In such cases I want to remove everything after "keep" exept for one special case where I want to keep the whole string (e.g. "keep / keepalso"). I tried doing so by setting up conditional values for the "text to replace" parameter with this logic:

IF attribute contains "/"

 

AND Attribute != "keep / keepalso"

 

Output = regex _/.*$,

 

ELSE Output = <empty>

 

 

In other words the StringReplacer should either replace the regex with an empty string (exept for "keep / keepalso") or do nothing.

 

It seems to work for replacing all " / remove" substrings but also overwrites all other instances with empty values.

 

 

Is it even possible to do what I want to do with one StringReplacer? Thank you for your help.

2 replies

ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • October 24, 2017

This works for me


pflegpet
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • October 24, 2017
ebygomm wrote:

This works for me

Thanks, now it works for me too. I had set the value for non-matches to "empty string" instead of "do nothing". Must have happened when I tried different settings on the transformer. I would not have guessed that this actually works despite the red background on the output value.

 

 


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