小编Dev*_*ile的帖子

如何按范围替换字符串?

我需要用范围替换字符串示例:

string = "this is a string";//I need to replace index 0 to 3 whith another string Ex.:"that"
result = "that is a string";
Run Code Online (Sandbox Code Playgroud)

但这需要是恐怖的.不能替换固定的单词......需要按范围

我试过了

           result = string.replaceAt(0, 'that');
Run Code Online (Sandbox Code Playgroud)

但这只取代了第一个角色而我想要第一个到第三个角色

javascript string replace

12
推荐指数
1
解决办法
1万
查看次数

标签 统计

javascript ×1

replace ×1

string ×1