About 4,030,000 results
Open links in new tab
  1. javascript - JS regex: replace all digits in string - Stack Overflow

    Jul 4, 2012 · s.replace(/\d/g, "X") which will replace all occurrences. The g means global match and thus will not stop matching after the first occurrence. Or to stay with your RegExp …

  2. javascript - How do I replace all occurrences of a string ... - Stack ...

    The str.replace(/abc/g, ''); (C) is a good cross-browser fast solution for all strings. Solutions based on split-join (A,B) or replace (C,D) are fast; Solutions based on while (E,F,G,H) are slow - …

  3. JavaScript String replaceAll() Method - W3Schools

    The replaceAll() method returns a new string with all values replaced. The replaceAll() method does not change the original string. The replaceAll() method was introduced in JavaScript 2021.

  4. Replace/Remove all Numbers in a String using JavaScript

    Mar 1, 2024 · Use the String.replace() method to replace or remove all numbers in a string, e.g. const replaced = str.replace(/[0-9]/g, '!');. The String.replace() method will return a new string …

  5. javascript - Regex to replace everything except numbers and a …

    Using replace and search to force a decimal number. const index = text.search(/(\.)/); if (index != text.length -1) {

  6. String.prototype.replaceAll() - JavaScript | MDN - MDN Web Docs

    Mar 13, 2025 · The replaceAll() method of String values returns a new string with all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the …

  7. JavaScript Replace All Numbers in a String - sebhastian

    Sep 26, 2023 · Today I’ll share a simple trick to replace all numbers from a string in JavaScript. All you need to do is to use the String replace() method and a regular expression to find all the …

  8. JavaScript String replaceAll() method (with examples)

    Feb 14, 2024 · The replaceAll() method in JavaScript is a powerful tool for string manipulation, allowing developers to replace all occurrences of a substring within a given string with another …

  9. Using Regex to Replace Numbers in a String - John Kavanagh

    So, to replace sets of numbers within a string, with their text equivalents, we just need to stitch everything together: Use replace() method; Use the /g flag and + quantifier to match sets of …

  10. JavaScript replaceAll() – Replace All Instances of a String in JS

    Jul 28, 2022 · The replaceAll() method will substitute all instances of the string or regular expression pattern you specify, whereas the replace() method will replace only the first …

  11. Some results have been removed
Refresh