如何删除字符串中的索引位置范围

How to remove a range of index-positions in the string?

本文关键字:索引 位置 范围 字符串 何删除 删除      更新时间:2023-09-26

我有一个这样的字符串:

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);