in reply to acessing the contents of a file character by character

How big are the files? How many searches are going to be done vs how many updates to the files? If there are going to be many searches and few updates, I'd personally run them through a parser first and eliminate non-word characters and dead space, then lowercase what's left and save to copies of the original files. Then the copies are what I'd search for the keywords. If the files are under say 20 MB and there are going to be lots of searches, I could load each file into memory in its entirety instead of line by line, and assuming I only cared about whethere the keywords were present in the file or not, I could use index (since I lowercased) rather than regex, which is significantly slower with the i flag on.

I don't know what you're doing, but it's the wrong approach.

  • Comment on Re: acessing the contents of a file character by character