A random offset replace function | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
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 Respuestas
+ 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