Jump to content

Recommended Posts

Posted (edited)

I forgot to update this, I had responded to a topic with an updated PCRE for parsing individual items/options, so here's the updated code:

_StringParseParameters: Parse Parameters in a string: Returns an array as if a command-line parser split the elements, or if nothing found an @error.

Note there is a look-behind and look-ahead assertion to prevent grabbing quotes, while also allowing for cases where there are empty quotes (""):

Local $aParsedArray=StringRegExp($sStringToParse,'((?<=\s"|^")[^"]+(?=")|[^\s"]+)',3)

The only thing I'd do beforehand is expand any environment strings like %windir%. All you'd need for that is to just set the "ExpandEnvStrings" option, assign the string to itself (looks dumb, but accomplishes the needed expansion), then reset the option. (or call the ExpandEnvironmentStrings API function)

The old version of this can still be found in a post I had made in the thread ' - it also parses comma-separated arguments, though retaining quotes. That could easily be remedied though.

Edited by Ascend4nt

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...