Last active
August 23, 2023 17:55
-
-
Save efenacigiray/9367920 to your computer and use it in GitHub Desktop.
Javascript replace char at index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function replaceAt(string, index, replace) { | |
return string.substring(0, index) + replace + string.substring(index + 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would be worth to have a
replaceAll
that makes use ofreplaceAt
but with index update like (withoutRegExp
of course)A B dolor sit amet, consectetur adipiscing elit, sed do C tempor incididunt ut labore et dolore magna aliqua.\nA B dolor sit amet, consectetur adipiscing elit, sed do C tempor incididunt ut labore et dolore magna aliqua.\nA B dolor sit amet, consectetur adipiscing elit, sed do C tempor incididunt ut labore et dolore magna aliqua