RegExp with multiple \\b word and @substitute

Marcus's icon

Hello there,
I am trying to parse a series of texts and replace some words with others, by using RegExp with \\b and @substitute.
At present I need to scan the texts and see if they contain any or more instances of quite a large group of words (above 2000 words altogether).
For this reason I have concatenated a long series of RegExp objects. (see example)
This is working, however it will take me a very long time to write hundreds of RegExp objects, each one with its specific word to de identified and word to be replaced with.
Does anyone know if there is a quicker dynamic method by which I can use jus one (or few) RegExp objects and simply have:
The texts to be parsed (that's fine)
- A one list of Awords, to be searched for
- B one list of words to replace the Awords if found?

Thank you so much in advance for your tim and help.

All the best

MM

Max Patch
Copy patch and select New From Clipboard in Max.

broc's icon

Instead of [regexp] you could use a loop with the [substitute] object.

Max Patch
Copy patch and select New From Clipboard in Max.

Marcus's icon

That's great! I didn't know of [Substitute], thanks for sending the patch over!!!!
I am connecting a coll to it, and looping the source text, so that it goes through each word that needs to be checked and eventually replaced. Thank you so much!