About 150,000 results
Open links in new tab
  1. javascript - How do I replace all occurrences of a string ... - Stack ...

    Given a string: string = "Test abc test test abc test test test abc test test abc"; This seems to only remove the first occurrence of abc in the string above: string = string.replace('abc', ''); How do I …

  2. string - How to replace several words in javascript - Stack Overflow

    I wanna replace several words in a text using replace () in javascript, how can I do that? For example, if I wanna replace, ' Dave Chambers, David Chambers, Will Smith ' with ' Jackie …

  3. javascript - Replace multiple strings with multiple other strings ...

    The string is "I have a cat, a dog, and a goat." However, this does not produce "I have a dog, a goat, and a cat", but instead it produces "I have a cat, a cat, and a cat". Is it possible to …

  4. How do I replace a character at a specific index in JavaScript?

    I have a string, let's say Hello world, and I need to replace the char at index 3. How can I replaced a char by specifying an index? var str = "hello world"; I need something like str.

  5. javascript - Replace multiple characters in one replace call - Stack ...

    Feb 18, 2022 · If you want to replace multiple characters you can call the String.prototype.replace() with the replacement argument being a function that gets called for …

  6. JavaScript: replace last occurrence of text in a string

    Apr 25, 2017 · You can use String#lastIndexOf to find the last occurrence of the word, and then String#substring and concatenation to build the replacement string. n = str.lastIndexOf(list[i]);

  7. javascript - How to remove text from a string? - Stack Overflow

    May 1, 2012 · In Javascript, there is no remove function for string, but there is substr function. You can use the substr function once or twice to remove characters from string.

  8. How can I replace specific word combinations in a string in …

    Jan 19, 2021 · I am currently learning javascript, and trying to automate a program that automatically detects unshortened acronyms and replaces it in a body of text. For example, …

  9. javascript - Replace words in the body text - Stack Overflow

    May 5, 2017 · To replace a string in your HTML with another use the replace method on innerHTML: document.body.innerHTML = document.body.innerHTML.replace('hello', 'hi'); …

  10. Javascript: regex for replace words inside text and not part of the ...

    Mar 16, 2013 · A word character is defined as [a-zA-Z0-9_] in JavaScript. Start-of-string and end-of-string positions can be word boundaries as well, as long as they are followed or preceded …

Refresh