I have a regex pattern which matches different expressions but i want both matches to be in the same capturing group. Currently i got the following regex:
-([^\s"]+)|-"(.+?)"
This does in fact match both (-hello -"Hello World") but in different groups (-hello = group1 and "Hello World" = group2).
In fact I got a working example, which is unfortunately not possible in Java regex:
(?|-([^\s"]+)|-"(.+?)")