A random offset replace function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

A random offset replace function

Is there a function for replacing a substring from a certain position (not from the beginning) in Javascript ?

9th Nov 2018, 6:08 AM
ะะปะตะบัะตะน ะ’ะฐัะธะปัŒะตะฒ
ะะปะตะบัะตะน ะ’ะฐัะธะปัŒะตะฒ - avatar
3 Answers
+ 2
You can use replace() it'll replace a substring with new string you provided But if you want to replace a substring from certain index, you'll need to write the function yourself its pretty simple, substring 0 to startindex, add the new string, add substring from endindex to end string
9th Nov 2018, 6:23 AM
Taste
Taste - avatar
+ 1
Substring and substr can do that First parameter is the offset
9th Nov 2018, 6:13 AM
Taste
Taste - avatar
0
But I need to replace the substring
9th Nov 2018, 6:17 AM
ะะปะตะบัะตะน ะ’ะฐัะธะปัŒะตะฒ
ะะปะตะบัะตะน ะ’ะฐัะธะปัŒะตะฒ - avatar