How can I replace a match only at a certain position inside the string?

后端 未结 5 1876
盖世英雄少女心
盖世英雄少女心 2020-12-06 02:43

So, I have a function which has two params: string and match index to replace and i need to replace only match with that index. How can i do that?

Example:

5条回答
  •  独厮守ぢ
    2020-12-06 03:20

    Use regex match with g flag var str="test string".match(/t/g) output would be array of matched strings in this case "t" [t,t,t]

提交回复
热议问题