Pentaho

 View Only

 how to use variable in the search field in step 'Replace in string'

johan nuyts's profile image
johan nuyts posted 11-16-2022 06:05
Hi
In the step  'Replace in string' the search field is filled like this ${var1} .  The content of var1 is filled.  Use RegEx is set to No, and the replace field is also set with a field (var2).  The result is that the content of the field ('replace with field') is used many times in the new out stream field.
I tried also using the RegEx like this \w${var1} but this results also like previous test. 
If I set in the search field just the words to be replaced, then everything is working fine.  

Do you have any suggestion how the use the variable in the field search ?

Regards
Johan

Attachment  View in library
data.txt 1 KB
Petr Prochazka's profile image
Petr Prochazka
Hi Johan,
you have 2 choices how to replace string in field.
  1. Use field Replace with  where you can use variable or constant. Variable can be set outside of transformation, for ex.
  2. Use field Replace with field where select field from stream and this value of field replaces search pattern. See example trans or screen
If you don't fill Out stream field then step replaces value in field.