I'd like to parse a custom scripting language, which reliably formats its various commands in the following format:
cmd arg1 arg2 ... argN
wheree different commands may have different numbers of arguments. For most arguments, this is pretty easy to do using strsplit(), as they are either numbers or single words separated by spaces. However, users can use multiple words as a single argument by surrounding it with double quotes (e.g. "single arg"). Is there a nice way for me to parse this? That is, can I take:
cmd 0.1 hello "single arg"
and return
ans = 'cmd' [0.1] 'hello' 'single arg'
as opposed to what I get now:
ans = 'cmd' [0.1] 'hello' '"single' 'arg"'
Any help or ideas are appreciated, thanks!
Chad
Best Answer