is it possible to get a regular expression that do:
- find first occurence of some word in a string
- return a substring of a nr of letters before and after the occurence
- but if it encounters a . (dot) before the nr of letters before and after occurence, it will just return the sub string before/after the dot.
- return whole words
example:
"Anyone who knows how to do this. Create a program that inputs a regular expression and outputs strings that satisfy that regular expression. And bla bla"
if the keyword is 'program' and we put nr of letters to 20 it will return 20 letters before and after 'program'. But since it encounters a dot before it gets to 20 letters it will stop there.
"Create a program that inputs a regular..."
Is this possible with regexp? what php function do i have to use? is there any finnished script for this? I guess its a quite basic need when showing search results. Someone already got the function to share?