Comment: \
Doc: This regex will split the commandline in arguments
Details:
The arg variable will contain all the different arguments
argument delimiters are in two categories :
whitespaces delimiters : \t \n \r \v ' '
',' : is a delimiter in the windows cmd
but it's not one in the powershell
quotation delimiters : \' \` \"
Variables:
arg : will contain each argument
Next variables can be adjusted by adding or deleting delimiters
quote_delimiters : quoted argument delimiters
whitespace_delimiters : whitespace argument delimiters
Comment: \
Group arg(?<arg>(?#\
)(?<arg_quote>(?#\
)(?<quote_delimiters>"|'|`)(?#\
)(?:(?#\
)(?!\3)(?#\
)(?<escape>(?(?!\\)[\x00-\xFF]|[\x00-\xFF]{2}))(?#\
))*(?#\
)\3(?#\
))|(?<arg_whitespace>(?#\
)(?:(?#\
)(?!(?#\
)(?<whitespace_delimiters>\s|$)|(?#\
)(?P>quote_delimiters)(?#\
))(?#\
)(?P>escape)(?#\
))+(?#\
))(?#\
)) 1st Alternative(?#\
)(?<arg_quote>(?#\
)(?<quote_delimiters>"|'|`)(?#\
)(?:(?#\
)(?!\3)(?#\
)(?<escape>(?(?!\\)[\x00-\xFF]|[\x00-\xFF]{2}))(?#\
))*(?#\
)\3(?#\
)) Comment: \
Group arg_quote(?<arg_quote>(?#\
)(?<quote_delimiters>"|'|`)(?#\
)(?:(?#\
)(?!\3)(?#\
)(?<escape>(?(?!\\)[\x00-\xFF]|[\x00-\xFF]{2}))(?#\
))*(?#\
)\3(?#\
)) Comment: \
Group quote_delimiters(?<quote_delimiters>"|'|`) "the literal " (3410 / 428 / 2216)
'the literal ' (3910 / 478 / 2716)
`the literal ` (9610 / 1408 / 6016)
Comment: \
Non-Capturing Group(?:(?#\
)(?!\3)(?#\
)(?<escape>(?(?!\\)[\x00-\xFF]|[\x00-\xFF]{2}))(?#\
))* *repeats the group contents below any number of times:
Comment: \
\3the text saved by group 3
Comment: \
Group escape(?<escape>(?(?!\\)[\x00-\xFF]|[\x00-\xFF]{2})) Condition(?(?!\\)[\x00-\xFF]|[\x00-\xFF]{2}) Uses the first branch if the lookaround matches
\\the literal \ (9210 / 1348 / 5C16)
If the condition is true, match this branch:[\x00-\xFF] Character Class[\x00-\xFF] \x00-\xFFone character from