How to replace all occurrences of a string in JavaScript




See post https://flaviocopes.com/how-to-replace-all-occurrences-string-javascript/

Regular expressions: https://flaviocopes.com/javascript-regular-expressions/

Get my book “The Developer’s Guide to Having a Successful Blog” https://flaviocopes.com/book/blog/

Original source


6 responses to “How to replace all occurrences of a string in JavaScript”

  1. Thank you, just one question. How to replace a word that sometimes is in the beginning of the sentence and it is capital. For example, "Hello from Italy, hello from Norway" How can I replace both "Hello" and "hello" to "hi" and keep the first hi Capital "Hi" ?

Leave a Reply