I am trying to extract a pattern with two words/terms but only when they occur inside a sentence, in this test case both "pattern" and "sentence". So:
Find the pattern when it is. In the same sentence. Find the pattern when it is in the same sentence.
Should only find a match in last sentence.
As you can see in my Regex101 test, (?P<Capture>pattern.*?sentence).*?\.
finds it regardless:
https://regex101.com/r/xDIU5q/2
As far as I understand, I have asked regex to non-greedily match until it finds a period. But this doesn't seem to be limiting it to do so.