Find and replace - list of characters (but replace only once)



Tree 1. : container containing text items

List 2.: List of textual ‘characters’ that have to be Replaced (note: these items can consists of more than 1 character)

Three 3: List of Replacement ‘characters’

Because there are multiple character that I would like to ‘Replace’ I found the - Replace text (multiple) - (Wombat plugin quit handy :slight_smile:

Unfortunately I noted the following:
The component start comparing (and replacing) in order of list 2. (correctly).

However, as a result it is possible that the item that is ‘already’ replaced, is replaced ‘again’ because it contains a character that is ‘recognized & replaced’ is present lower in list 2.

Bottom line:
I would like to translate multiple items (which is possible whit the ‘replace text multiple’ component of wombat). However, when an item is ‘Replaced’, I would like to ‘fix’ this part, this so it not Replaced ‘again’…

Maybe something in python? (I am not a python expert)

2021-01-24 Replace text based on multiple (15.4 KB)

See example above, Note: this is an simple example with numbers but the solution has to be generic/also applicable with Letters… (In this example to make it easy to follow the replacing number should be simply -1)

Any suggestions?

Thanks :slight_smile:

This could be one way.

2021-01-24 Replace text based on multiple (17.8 KB)


Hi Kim,

Thank you for your response.
But unfortunately this is not the solution because it can also be the case that all items (in the find list) are present.

I tried several thing in grasshopper, I more and more get the feeling this can only be achieved in Python :sweat_smile:.

Or do you have any more creative solutions? :slight_smile:

Looks like you want to replace integer numbers, not characters, with their value minus one?

domain_replace_2021Jan25a (7.2 KB)