Skip to main content
Solved

Is there a transformer that can use generic expression (using string functions) for a group of attributes?

  • December 16, 2020
  • 6 replies
  • 39 views

thijsknapen
Contributor
Forum|alt.badge.img+10

It seems to me like I'm looking for a transformer very similar to the ExpressionEvaluator with 'Evaluation Mode' = 'Overwrite existing Attributes', only without the numeric evaluation (that doesn't seemingly 'wrap' the expression in a arithmic editer).

 

I thought about posting an idea about this (e.g. create new transformer or add parameter 'evaluation mode' = (text|arithmetic) to ExpressionEvaluator), but just wanted to check if I'm maybe overlooking existing functionality.

 

Attached is a workspace that illustrates the numeric evaluation possibilities in the ExpressionEvaluator, and an example of how I would like to have the option for a 'text evaluation' possibility to e.g. add '_concat_@CurrentAttribute' to each attribute in the selected group.

 

 

Best answer by ebygomm

The StringConcatenator will let you do this, you need to switch to the Advanced Editor to set it upCapture

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

6 replies

ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • Best Answer
  • December 16, 2020

The StringConcatenator will let you do this, you need to switch to the Advanced Editor to set it upCapture


thijsknapen
Contributor
Forum|alt.badge.img+10
  • Author
  • Contributor
  • December 16, 2020

@ebygomm​ I did not know about that option. Tnx :)


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • December 16, 2020

It's also possible to use the StringReplacer to do the same thing.

Use regex to match the beginning of the string, and replace the beginning(which has 0 length) with the value you wantCapture 


thijsknapen
Contributor
Forum|alt.badge.img+10
  • Author
  • Contributor
  • December 16, 2020
ebygomm wrote:

It's also possible to use the StringReplacer to do the same thing.

Use regex to match the beginning of the string, and replace the beginning(which has 0 length) with the value you wantCapture 

Check. I knew about that transformer, but I didn't think about using it for this setting.

Nevertheless it doesn't seem to handle the @CurrentAttribute very well within the Replacement Text, or e.g. @Evaluate(...) within the string, whereas the StringConcatenator does work with these

 

Addendum.

I guess this doesn't really work so well due to the regex evaluation mode. For example, the brackets in @Evaluate(...) would be interpreted as a group, and probably string/math functions wouldn't be evaluated because it is performing the string as a regex, and not an (evaluation) expression

 

 


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • December 16, 2020
thijsknapen wrote:

Check. I knew about that transformer, but I didn't think about using it for this setting.

Nevertheless it doesn't seem to handle the @CurrentAttribute very well within the Replacement Text, or e.g. @Evaluate(...) within the string, whereas the StringConcatenator does work with these

 

Addendum.

I guess this doesn't really work so well due to the regex evaluation mode. For example, the brackets in @Evaluate(...) would be interpreted as a group, and probably string/math functions wouldn't be evaluated because it is performing the string as a regex, and not an (evaluation) expression

 

 

The @CurrentAttribute isn't required, as you are only replacing the matched element, any unmatching parts, i.e. the rest of the attribute, remain as is. The replacement text just needs to include the text you want to add.

 

If you want to do anything more complicated you need to match the attribute as a group instead e.g. where \\1 is effectively your current attribute as the regex matches everything

CaptureI think you're correct that it won't work with @Evaluate though.


thijsknapen
Contributor
Forum|alt.badge.img+10
  • Author
  • Contributor
  • December 16, 2020
thijsknapen wrote:

Check. I knew about that transformer, but I didn't think about using it for this setting.

Nevertheless it doesn't seem to handle the @CurrentAttribute very well within the Replacement Text, or e.g. @Evaluate(...) within the string, whereas the StringConcatenator does work with these

 

Addendum.

I guess this doesn't really work so well due to the regex evaluation mode. For example, the brackets in @Evaluate(...) would be interpreted as a group, and probably string/math functions wouldn't be evaluated because it is performing the string as a regex, and not an (evaluation) expression

 

 

Hi @ebygomm​ I know about the Regex options, and I have used this transformer before on multiple attributes.

My question for this topic was quite generic, where I would like to use evaluations using e.g. CurrentAttribute. That didn't work, and also e.g. @Evalutate(\\1*2) would work. This is no issue, since it does work for the StringConcatenator transfomer.

 

Thus, I already have my answer;

Arithmic evaluations on groups of attributes -> ExpressionEvaluator

Text (and/or arithmic) evaluations on groups of attributes -> StringConcatenator

Regex evaluations on groups of attributes -> StringReplacer


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