【发布时间】:2012-09-16 02:15:03
【问题描述】:
我需要按范围替换字符串 示例:
string = "this is a string";//I need to replace index 0 to 3 whith another string Ex.:"that"
result = "that is a string";
但这必须是动态的。不能替换固定词...需要按范围
我试过了
result = string.replaceAt(0, 'that');
但这只替换第一个字符,我想要第一个到第三个
【问题讨论】:
-
你试过什么?你看过 documentation 的字符串方法了吗?
标签: javascript string replace