in reply to search for exact word only

My script searches a copy of the original text that has had all non alphabet characters converted to spaces (except ' in words like isn't, which just disappears), all sections of spaces reduced to one space, and all letters converted to lowercase. A space has also been added to the start and end of each section. The search terms are then converted using this method too, and searches are performed for exact phrase, all keywords, and any keywords - depending of course on the number of search results at each level, and the number of keywords submitted.

This method seems to work well unless you want to return the section of text matched, in which case the copy can't be resized by having characters removed. You should certainly have a copy, though, since exact match searches are much faster than case-insensitive searches, and all text to be searched should be in one file rather than many.