Here is my input:
xxx999xxx888xxx777xxx666yyy
xxx222xxx333xxx444xxx555yyy
This is the expression:
xxx.*xxx(?<matchString>(.(?!xxx.*xxx))*?)xxx.*yyy
It's returning 444.
I'd like it to return both 444 and 777, but I can't get anywhere with this.
I have the ! exclusion so that it matches only the innermost on the left side (which works great when I am searching for only one result, which is most of the time). However, I have a feeling that that is related to why it is skipping the first result in this instance. I'm not sure where to go from here.
I've been testing here: http://regexlib.com/RETester.aspx (with "SingleLine" and "Explicit Capture" enabled)
Any advice would be appreciated!
First of all I want to explain why your current solution doesn't work:
Since you've enabled
SingleLine
option,.*
matches999xxx888xxx777xxx666yyy\nxxx222xxx333
, the pattern in parenthesis matches444
, and the rest of your Regex matchesxxx555yyy
.So to match both
777
and444
you can either disableSingleLine
option or use something like this: