Parse nested function call string in javascript

混江龙づ霸主 提交于 2021-02-10 14:21:00

问题


I want to parse the following string (using Javascript):

color(alias(sumSeries(sys.mem.free.*),"memory (free)"),"#00AA88")

into an array of function names and arguments:

[["color", "#00AA88"],
 ["alias", "memory (free)"],
 ["sumSeries", ""]]

plus extract the innermost string

sys.mem.free.*

The string is actually the target parameter from graphite. I don't want to write a parser myself (dealing with things like double quotes and brackets is hard to get right). Is there a library which helps with basic parsing?

Since it's not JSON I cannot go for a JSON parser.

来源:https://stackoverflow.com/questions/18772948/parse-nested-function-call-string-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!