I try to parse a expression like this with my regex:
FIRST SECOND ARG1=$value ARG2="with space"
There can be any number of arguments.
example: HELLO VERSION MIN=$min MAX=$max USER="xxx" PASSWORD="yyy"
result: HELLO - VERSION - PASSWORD - "yyy"
desired result: HELLO - VERSION - MIN - $min - MAX - $max - USER - "xxx" - PASSWORD - "yyy"
My regex is ([\w\d] ) ([\w\d] )(?: ([\w\d] )=("[^"]*"|[^" ]*))*
However, I do not get all the arguments, but only the last back. How can I fix it? It is too much for a regex?
CodePudding user response:
You can match what's between quotes first, then the rest.
(["].*?["])|([[:alnum:]_\$] )
Test here
