Long sequence of Regex replacements

I have a sequence of about 35 Regex replacements I apply in order to a string. Currently, I have the search and replace strings, and a flag that controls DotMatchAll, stored in an array which I loop through. However, maintaining the array takes some work if I add/delete a step, or change the order. Just wondering if there are any suggestions for a more easily maintained system for storing the Regex information.

Thanks

You can use a regex sworn in the pattern instead of using DotMatchAll, letting you get rid of that array. (I don’t recall which switch it is and can’t conveniently check on my phone.)

Or, instead of a dot, use [\s\S] in your patterns and don’t worry about the switch or flag.

Or, if you can, avoid a dot entirely by using a more precise pattern.

Thanks. There are a only a couple of the replacements that need to match new lines. I will try \s\S. That’s new to me and looks good.

I still need an array for the thirty odd pairs of search and replacement strings. When the number of replacements was smaller and (I thought) complete, I coded it by assigning them to a 2-D array. eg. myArray[0,0]= “…” etc. That coding was causing the problem.

I separated the array into single dimension arrays, and now I can use Append to add items. This also means I can change the order with simple cut and paste.

Thanks for your help.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.