I have a problem closely related to this question: Regex find match within a string
In that case the problem is to find Warner Music Group
instead of XYZ becomes Chief Digital Officer and EVP, Business Development of Warner Music Group
for
Ole Abraham of XYZ becomes Chief Digital Officer and EVP, Business Development of Warner Music Group.
which is solved using .*\bof\s+([^.]+)
Now I have a very similar problem, with the difference that I want all matches, and the previous solution returns only one. Here you have my basic setup with the solution above: https://regex101.com/r/bIbFaW/1
The problem is that for the string
This is a test with a string with punctuation, and an end. Then test words, and more text. And here whith more text with more punctuation, like that.
the pattern .*\bwith(.*?),
will only get me more punctuation
(a good match), missing an earlier option punctuation
from the first sentence.
Is it possible to do this or should I approach it differently? For example with(.*?),
gets all matches, but they are the longer options ( a string with punctuation
instead of punctuation,
). I could then try to find matches within my matches, but doing this at this moment has unrelated overhead which would be nice to avoid if possible.