I am using
boost::split(strs, r_strCommandLine, boost::is_any_of("\t "));
to spit a string into tokens for parsing a simple script. So far, so good. However, for the following string
command_name first_argument "Second argument which is a quoted string."
i would like my tokens to be
strs[0] = command_name
strs[1] = first_argument
strs[2] = "Second argument which is a quoted string."
Of course, I could search for quote characters at beginning and ending of tokens and merging using ” ” delimiters the tokens between the the occurrence of a token beginning with a quote and a token ending with a quote to recreate the quoted string but I am wondering if there is a more efficient/elegant way of doing this. Any ideas?
Example using
boost::tokenizer:Output:
See demo at https://ideone.com/gwCpug .