Logical Expression for matching Text String using IF ELSE

I likely need a nested IF Else RegEx series to incrementally concatenate/merge up to four strings currently in four columns (first series col 1, second series col 1 + col 2, third series col 1 + col 2 + col 3, forth series col 1+ col 2 + col 3 + col 4). Please see attached image (temp). This is the output of KNIME Term Neighborhood Extractor.

The Term Neighborhood Extractor creates these four columns in two directions: Right Neighbors and Left Neighbors.

The logic of the Right Neighbor matching is to first test the individual Term (col 1 (in the image col F)) for a text match (I will provide a library for string matching in a later step). If that single string matches a library then stop and place the string in the output column. If that fails then test col 1 + col 2 (first right neighbor (in attached image col J). If that combination matches a library then place concatenated string in the output column. If that fails then text col 1 + col 2 + col 3 for a text match. If that fails then cols 1+2+3+4. If all fails then terminate leaving a blank cell.

At the point of matching during a series the actual concatenated text is saved to the output cell. If no match then continue combining the next column.

For example, using the attached graphic: Row 8 (Right Neighbor) “mountain + views” = “mountain views”, which is tested against a library of terms. Row 11 (Right Neighbor) “upgrades” + “throughout” + “the” + “home” = “upgrades throughout the home” is grouped and tested against a library. Row 18 (Left Neighbor) “floors”… “gleaming” + “hardwood” + “floors” = “gleaming hardwood floors” and tested later against a dictionary.

The Left Neighbor matching is then similar but simply using different columns in a different order.

I’ve explored finding some videos on IF/THEN or IF/ELSE, but most are in Python, which appears to use different language expression than the KNIME Rule Engine needs for RegEx.

Thanks for your help.

This looks as pretty convoluted solution. Please look if solution based on indexing will work for you

thank you, i will take a look. i did not even know some of the nodes you suggested even existed :slight_smile:
I am also exploring how the concatenate function in the string manipulation node might at least create the 7 total options of my logic, then perhaps use the cell replacer node with a dictionary for the matching of the terms.