javascript - 如何删除字符串中的一系列索引位置?

标签 javascript jquery regex

我有一个像这样的字符串:

var str = "T  h  i  s     i  s     a              t  e  s  t";
//         1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17

现在我想删除这个范围:[11 - 13],我想要这个输出:

var newstr = "T  h  i  s     i  s     a     t  e  s  t";
//            1  2  3  4  5  6  7  8  9  10 14 15 16 17

我怎样才能做到这一点?

最佳答案

这应该可以做到:

var newstr = str.slice(0, 10) + str.slice(14);

关于javascript - 如何删除字符串中的一系列索引位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35109885/

相关文章:

javascript - 如何将数据表内容存储在本地存储中

r - 将列表类型列与 DF 中的其他列匹配

javascript - 如何将点击事件附加到 ExtJS 模板元素?

javascript - 使用 javascript 函数打开选项卡

javascript - 如何使用 Angular 通过 DOM 中的变量名称访问对象的键

javascript - 如何更新mysql json列?

javascript - jQuery:获取所有 Windows

jquery - 打乱数组元素

java - 字符串分割模式java

c# - 无法从字符串中过滤出内容