I'm making a program to split arguments in a string in Node.js, and I'm using .split(" "). Here's an example:
"arg1 arg2 (arg3,arg4)"
This returns:
["arg1", "arg2", "(arg3,arg4)"]
works as intended
But what I also want to do is take items in parentheses as 1 single object. For example:
"arg1 arg2 (arg3, arg_after_space)"
Returns ["arg1", "arg2", "(arg3,", "arg_after_space)"]
if using .split(" ")
What I want ["arg", "arg2", "(arg3, arg_after_space)"]
I want this to work with "", {}, (), [], and basically every symbol that is used as a pair in Node.js, but how can I do that?
I tried .split(" ") but just cannot figure out how to do that