繁体   English   中英

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

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM