(-[a-zA-Z]+=?)+(([^\s]+)|(\s+((["'])(?:(?=(\\?))\2.)*?\6)))
I have a bunch of command line arguments.
-arg1 -arg2 -arg3=500 -arg4=-250,200,50.0 -arg5 "Hello World" -arg6 "[I don't know whats going on /here/]"
I'm not particularly good at regex, and was using regexr.com to verify my results. Regex.Matches with the expression from this site usually works copy and pasted out no problem. This time its not.
The results of using that command line string is as follows:
Count = 6
[0]: "-arg1"
[1]: "-arg2"
[2]: "-arg3=500"
[3]: "-arg4=-250,200,50.0"
[4]: "-arg5"
[5]: "-arg6"
And this is looping through Regex.Matches and each Captures
I can't figure out why the quotes won't become part of the match. Is it maybe a whitespace issue with the |(\s+((["']
part?