Replace parts of strings in a list


Why do I end up with 4 items in the list?

Because you’re sending a list of replacement not a single item:

Change:

[“SN”] -> “SN”

2 Likes

Thank you :disappointed_relieved:

3
Thank you for all the responses.
Do you know if it is possible to remove duplicates from the list? I would later create a ‘String From List’ for another purpose.

List.uniqueItems, and use list levels (@L2)


Is it possible to change the code to change multiple groups of strings at once?
For an example FP and W are replaced with A.
S and RL are replace with B and so on.

The simplest way using what you already have would be nested if statements, although I think dictionaries might be a better idea if you have a lot of things to change.

Using @mellouze’s original method and using dictionaries to replace multiple:

The top part is the dictionary where you would set what should be replaced and what it should be replaced with. The entries have to match, so the first item at the top code block should match the first item at the code block below.

So FP is A, W is A, S is B, RL is B, and so on.

3 Likes

Thank you