regex - Splitting a string with double dash as delimiter containing both single & double dash in windows batch -


this piece of code working on.

set "comd=aws iam create-group --group-name xxx --user-name yyy"     /f "tokens=2,3delims=--" %%a in ("%comd%") (        echo %%a         echo %%b      ) 

i want take out group-name xxx 1 token , user-name yyy another, when use -- delimiter considers string - fit tokenized in case group of create-group being considered separate token.

i want make code work occurrences --key value.

the simplest thing can replace -- unlikely ~. e.g. set comd=%comd:--=~% before line.

your full block be:

set "comd=aws iam create-group --group-name xxx --user-name yyy" set comd=%comd:--=~% /f "tokens=2,3 delims=~" %%a in ("%comd%") (    echo %%a     echo %%b  ) 

you might have read of how parse command line arguments switch in batch file - few ideas there