I'm trying to greedy match string and mark it is as group until it encounter space dash ( -). So far I've got:
^ *-{2}([\w\d-]+)(=([ \w\d-]+))?(.*)|(.+)
and my test string is:
--match1=match2
--match1=match2 match2
--match1=match2 match2-match2
--mat-ch1=match2 match2
--match1=match2-match2 match2
--match1=match2 -lastmatch
--match1=match2 --lastmatch
--match1 -lastmatch
--match1 --lastmatch
lastormatch
Every each kind of match (match1, match2, lastmatch, lastormatch) should be grouped together if they are next to each other. This is working for every line, except 6 and 7. Basically '-' should act as delimiter when it comes to match2 group (but - surrounded by /w/d is fine as part of string inside group). I know, that lookahead/lookbehind should be used, but I can't get it right.
What I have comparing to what I need
regex101.com