Masking a string

Hi,
I have in one column strings with 16 chars. Furthermore I have 16 further columns which shall mask (replace) a certain character in the 16 chars-string if the column contains a 1.

I have done this with 16 rule engine/column merger. But it’s very slow and not very fail-safe to code.

Is there a more convenient way with less nodes?

Column Aggregator may work for you.

The column aggregator node would help to combine the 16 different mask/replace columns. If I would have one column then which holds the 16 character strings and a further column which contains the 16 character mask information, which node could I use then to get to the result?

For example I would have in one column: “ABCDEFGHIJKLMNOP” (16 characters) and in the mask column: “0010100000000001” which shall result in “AB-D-FGHIJKLMNO-”

Hi!

Not sure you can accomplish it without coding. For example I used Column Expression node who has JavaScript syntax…

Here is the code from it. Column1 is your ABC… string and column2 is your mask.

var newstr=[];

for (i=0;i<16;i++){
    if(column("column2")[i]==0){
        newstr[i]=column("column1")[i];
        }
    else{
        newstr[i]="-";
        }
    }
newstr.toString();
replace(newstr,"," ,"" )

Br,
Ivan