In the unlikely case that this is a problem, it's fairly straightforward to switch ...I think we are not so far apart on this.
Switching involves abandoning one approach to solving the problem (and I might more clearly have expressed the idea that 'this approach' meant 'read the entire file to a string, operate on the string, and write the string back to a file') for a significantly different approach, perhaps one of those outlined in the balance of your reply. This is what I mean when I write that the approach does not scale well.
I agree that, given what one can divine about the OPer's data from the OP, the problem is not likely to arise. In fact, I would go further and say that, in my experience, problems like this never happen – until they happen, and then you have to go back and change a bunch of stuff and re-test everything; which, while straightforward, still costs time, effort and risk; hence, the caution about lack of scalability.
In reply to Re^4: Help with multiple line regex subsitution
by AnomalousMonk
in thread Help with multiple line regex subsitution
by gator456
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |