Trying to use regex to parse arguments from a string: "-a 1 -b -5.1"
.
Output should have 2 flags with values: flag a
with value 1
, b
with -5.1
.
When I try (-(?<flag>[a-zA-Z])(?<value> .+)?(?!-[a-zA-Z]))*
regular expression, it returns only flag a
with value 1 -b -5.1
.
Why doesn't it stop at -b
?