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. How to replace an apostrophe in a string in Javascript?

    var str = "this's kelly" str = str.replace(/'/g, 'A'); The reason your version wasn't working is because str.replace returns the new string, without updating in place. I've also updated it to use the …

  3. Efficient Javascript String Replacement - Stack Overflow

    Jan 20, 2017 · Explore efficient methods for replacing strings in JavaScript, including examples and best practices, discussed by the Stack Overflow community.

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

    In JavaScript, strings are immutable, which means the best you can do is to create a new string with the changed content and assign the variable to point to it.

  5. How to replace part of a string using regex - Stack Overflow

    Apr 28, 2017 · ) - end of capturing group #1 (its value can be accessed with $1 backreference from the replacement pattern) [^\]]* - 0+ (as the * quantifier matches zero or more occurrences, …

  6. Javascript - how to replace a sub-string? - Stack Overflow

    String.replace() is regexp-based; if you pass in a string as the first argument, the regexp made from it will not include the ‘g’ (global) flag. This option is essential if you want to replace all …

  7. string - JavaScript replace () method dollar signs - Stack Overflow

    Aug 10, 2016 · The function's result (return value) will be used as the replacement string. (Note: the above-mentioned special replacement patterns do not apply in this case.)

  8. 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 …

  9. Why do i need to add /g when using string replace in Javascript?

    Jul 30, 2009 · A list of useful modifiers: g - Global replace. Replace all instances of the matched string in the provided text. i - Case insensitive replace. Replace all instances of the matched …

  10. How to replace substring in Javascript? - Stack Overflow

    Jul 27, 2011 · To replace substring.But not working for me... var str='------check'; str.replace('-',''); Output: -----check Jquery removes first '-' from my text. I need to remove ...

Refresh