Back when I was programming in C, I came across this kind of problem all the time. Here's the approach that I used:
- Grab an 8K chunk of the file
- Search for the thing you're looking for in the first half of the chunk less the length of the search string.
- Once you've looked at most of the first chunk, scroll everything down by 4K, read in another 4K chunk where the empty space was created, and repeat from the previous step.
Instead of using a regex, I'd probably use index(), but if that's too slow I would just write a C program to do the job.
--t. alex
"Here's the chocolates, and here's the flowers. Now how 'bout it, widder hen, will ya marry me?" --Foghorn Leghorn