javascript - 使用 PrototypeJS 将元素转换为数组

标签 javascript prototypejs gsub

假设我有一个字符串 - invoice[level1][level2][level3] 并且我使用 Prototype 作为 Javascript 框架。

如何将该字符串转换为这样的数组 ['level1', 'level2', 'level3']

最佳答案

删除所有内容,直到开始[。删除结尾的 ],然后拆分 ][

str.substring(str.indexOf('[') + 1, str.length - 1).split('][')

关于javascript - 使用 PrototypeJS 将元素转换为数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6130949/

相关文章:

javascript - 对象不支持 Internet Explorer 中的属性或方法 'previous'

html - prototype - 从 DOM 中删除元素时触发事件

regex - 如何使用gsub提取两个句点之间的单词

javascript - Bootwatch 模板上的 jquery 转换问题,与 Meteor 集成

javascript - 如何在javascript中执行旋转变换?

javascript - 未捕获的类型错误 : Cannot read property 'text' of undefined for getting selected value in java script

Ruby 将 gsub 与正则表达式结合使用

javascript - zimbra zimlet 从后端上传公文包文件夹中的文件

javascript - mixins 中的 prototype.js 实例属性

awk gsub 和神秘的 "1"