I am looking for the best way to do this... does some handy regex exist? Or I should play with it in cycle somehow section by section?
Okay I have such a sentence:
"The rooms rooms and rooms again were great, the food was not but the beds were extremely comfortable."
I have an array of items (delimeters):
array('food','room','bed');
I would like to somehow magically obtain the sections of sentence between these words...like split it (from one delimeter to another) if it's understandable...
The first section:
"The"
The second section (until closest item from array (delimeter):
"rooms "
The third section:
"rooms and "
The fourth section:
"rooms again were great, the"
And the fifth section:
"food was not but the ".
And the fourth section:
"beds were extremely comfortable."
Basically split the sentence from one key word to another repeatedly.
The point of delimeters is to split the sentence... so just match it... if in sentence there is a word "rooms" it matches the delimeter "room". Plural is not important, the point is to split the sentence to multiple sections based on delimeters (items from array).
Any idea please?