There are other questions referring to this on Stack Overflow such as how-to-parse-a-string-and-return-a-nested-array?
But they all refer to lists in the format of ((abc)de(fg)))
. going to the form:[['a','b','c']'d','e'['f','g',]]]
I have a list of the form:
((wordOneWord2)OtherWord(FinalWord)))
By using the methods I learnt from the other questions by nested list was of the form:
[['w','o','r','d','O','n','e','W','o','r','d','2']'O','t','h','e','r','W','o','r','d',['F','i','n','a','l','W','o','r','d']]]
rather than the desired
[['wordOneWord2'], 'OtherWord', ['FinalWord']]
I can achieve the desired result by parsing the list letter by letter and then concatenating the items within each list back together but it takes more code than I think necessary, is there a faster way of doing this?
Based on this solution by falsetru: