I'm splitting code via regular expressions and it's doing (sort of) the right thing... until the string ends. Would this be a problem with my regex? If so, how would I fix it?
Code:
let args = line.split(/\s(?=(([^"]*"){2})*[^"]*$)/);
console.log("LINE: "+line)
console.log("SPLIT: "+JSON.stringify(args))
Output:
LINE: var String: test = "Hello"
SPLIT: ["var","String: test = \"Hello\"","Hello\"","String:","test = \"Hello\"","Hello\"","test","= \"Hello\"","Hello\"","=","\"Hello\"","Hello\"","\"Hello\""]
Expected Output:
LINE: var String: test = "Hello"
SPLIT: ["var", "String:", "test", "=", "\"Hello\""]