Replacing items in a list based on items in another list

The image below explains what I’m after. I can get it to work with one value by using ReplaceByCondition and the String.Contains node, but for the life of me I cannot figure out how to make it work for a list. I need to iterate through each item in List A and search each item in List B. Once found, replace with the item found in list B, then move on to the next item in List A & repeat. Any ideas? I’m tired and stuck :slight_smile: Thanks!

ListReplace

I just stumbled through this same process the other day. But I will have to wait until I’m at a computer to send you the solution I had. I’ll try to this evening.

Oh thanks a lot, no rush :slight_smile:

Hi David,

We’ve got a ton of options when dealing with strings. If I have to stick with the core nodes, I’d try something along the lines of this:

2015-05-10_23-08-38

Thanks a lot Dimitar. I was actually close to the solution you suggested with another iteration of mine (didn’t use cross product lacing to get to the nested list of True & False as you can see below), but didn’t think of the technique you used to get the item numbers and then rebuild the resulting list from the search list B. I thought there was a more efficient way to do this just in case List B was long as well, but I suppose there just isn’t as efficient a way as one could do in a script, such as when nesting multiple loops. Below is what I’m going with for the moment. Again, thanks for responding!

Solution

It looks like you got it working. My method was for replacing null values. so it was n’t exactly the same after all anyway.

I’m starting to save up these examples for when I need to use them down the line and forgot how to achieve!. In this particular case, I’m going to use this to work around a bug where level data is not reported consistently. Through this “find & replace” method, I can clean up the data and continue on rather than wait for the bug to be fixed.