See Matching in huge files for a sliding buffer technique that lets you run a regex that might match multiple lines on a huge file, without needing to pull the entire file into memory. What the technique doesn't support, at least not directly, is doing substitutions. But you might be able to adapt it to your purposes.
In reply to Re: regex large named.conf parsing
by dws
in thread regex large named.conf parsing
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |