要解析的字符串(不带空格):
"instrumentalist ( bass (upright , fretless , 5-string ) , guitar ( electric , acoustic ) , trumpet ), teacher , songwriter, producer"
我需要在 Ruby 中得到这个结构
["instrumentalist",[["bass",["upright","fretless","5-string"]],["guitar",["electric","acoustic"]],["trumpet"]],["teacher"],["songwriter"],["producer"]]
因为嵌套了,(
帮不了我。我真的不知道是否有一个花哨的 RegEx 可以提取这种类型的字符串。还是我必须使用词法分析器?)
,
String#partition