Replace parts of strings in a list

Is it possible to replace the strings of the following highlighted area.
Each time one of these string parts appear, it should be changed to SN.

I used many string replacement methods, but was not successful.

What do you mean by FP,W,RL = SN? Can you show or write what you want the output to be with the example in the picture?

This should at least help you get started:

Same graph, more string examples:

Result should look like this

If you want to replace individual parts, you should replace it before combining into one string.

Also you might want to edit your original post:

You want it to be changed to SN, not RL

sorry for that, to SN yes!

Still trying to get this done without repeating nodes or using complicated python but for now, this works:

You would feed that into the String from List node

1 Like

Thank you for the response, is it possible to do this all at once using a python code?
I have many values to replace.

That depends, would list levels stay the same? If yes, then you could use python. If not, then you would have to make a recursive function which is way too much work.

List levels would stay the same

I think this would be simpler :slight_smile: Have not teste it for multiple sublists though.

Try with the same list levels, that was what was making it more difficult.

I meant the list levels would be same as the picture I uploaded, will not change further. (Would be a NO for your question, not the same list level)

Haha you answered it right the first time. If the list levels are the same as what was in the original picture, I can make a quick python script in a minute.

Changed the nodes so it could match the levels :slight_smile:


Never seen the @@L1 before. That’s what I needed!

Yes, it is pretty useful :slight_smile: You just have to turn on the “Keep List Structure” below “Use lists levels”. The syntax is the same in a CodeBlock

What version is that in? I am in Dynamo 2.0.1 and I can’t put in @@, I have Keep List Structure and Use List Levels on.

You need to close the graph and re-open it (or swith tabs). It is just a visual bug, but it should work anyway.

1 Like

Sweet, that’s great to know! Thanks

1 Like

Just another suggestion to the pool :slight_smile: