I have a regex with two named parts and an optional hyphen separator.
^(?<Left>xxx)-?(?<Right>yyy)$
(I've simplified the actual regex down. Instead of 'xxx' and 'yyy', imagine two really long and complicated regexes.)
However, because the hyphen is optional, there are input strings where the implied separator could be added into different places. Is there a way I can resolve the ambiguity by saying that Left or Right should take the larger share of the input string?
For example, for an input "ABCDEF" that could be split as either "ABC"/"DEF" or "ABCDE"/"F" with both being valid matches of the two sub-regexes. Say I prefer the second split because I want 'Left' to take the largest chunk it can so long as 'Right' is left with a valid remainder.
I'm using .NET's regex library, but I hope there's a standard technique.