Unfortunately, with the wonder of hindsight, just about everybodies code could be improved once its been created. Looping through every character is horrendously slow and it appears you are probably doing this more than once so that magnifies it.
It might be worth taking a step back and looking at your requirements once again to see how to make the code really efficient. I would recommend getting away from Selections and strings in favour of ranges.
For the job you describe here it would be WAY faster to do find/replaces instead of looping characters.
eg with wildcards on find "([! ])\[\[" and replace with "\1 [[" to ensure there is always a space in front of any opening double square brackets
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
|