I've been working with this one for a while, and am stumped. I would assume there's a way to do it, but I sure don't know how. Knowing my luck, its probably simple, too.
I have a search engine I'm building for our site, and it is coming along nicely, with one exception. My script needs to find a matching word in the story body, which is easy.
However, it also needs to extract more than just the matching word. It also needs to take a certain amount of words to the left and right of the matching word.
The idea is to extract a portion of the story surrounding the matched word, so it will show the context in which the word was used.
Example story body:
"Php regular expression matching is awesome but sometimes a bit difficult to construct."
Lets say my matching word was 'sometimes' and that I need 2 words to each side. I would need to extract 'awesome but sometimes a bit' from the story.
If anyone could help me with this, that would be great... I'm pulling my hair out at this point.
Thanks a bunch...