In the following text
My cow always gives milk. Your cow sometimes produces milk.
I want to extract
'always gives', 'sometimes produces'
Using the encapsulating strings "cow" and "milk".
I tried "cow(.*)milk" following Regular Expression to get a string between two strings in Javascript however it only works if the first sentence is alone
My cow always gives milk.
In my case, using that regular expression returns
always gives milk. Your cow sometimes produces
Additionally, I have also tried "(?<=foo)[^bar]*(?=bar)" from Extracting all values between curly braces regex php. And this works great. For example (and this is closer to the actual problem I'm trying to solve)
fooSTRINGbar fooCHARACTERSbar
Returns
'STRING', 'CHARACTERS'
Great! But for some reason if "STRING" contains a character that "bar" has, then the match fails. For example,
fooSTRaINGbar
Doesn't return anything.