I would like to convert the following string into an array/nested array:
str = \"[[this, is],[a, nested],[array]]\"
newarray = # this is what I need help w
For a laugh:
ary = eval("[[this, is],[a, nested],[array]]".gsub(/(\w+?)/, "'\\1'") )
=> [["this", "is"], ["a", "nested"], ["array"]]
Disclaimer: You definitely shouldn't do this as eval
is a terrible idea, but it is fast and has the useful side effect of throwing an exception if your nested arrays aren't valid