I have a question on how to properly parse the string like the following,
"(test.function, arr(3,12), "combine,into one")"
into the following list,
['test.function', 'arr(3,12)', '"combine,into one"']
Note: the 'list' items from the original string are not necessarily split by a comma and a space, it can also be two items split directly by a comma one after another, e.g. test.function,arr(3,12)
.
Basically, I want to:
- Parse the input string which is contained in parentheses, but not the inner parentheses. (Hence,
nestedExpr()
can't be used as-is) - The items inside are separeted by commas, but the items themselves may contain commas.
Moreover, I can only use scanString()
and not parseString()
.
I've done some search in SO and found this and this, but I can't translate them to fit into my problem.
Thanks!