Skip to main content

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.

This works for me


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.

 

 


Reply