About 148,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('ab...

  2. 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.

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

  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. How to replace part of a string using regex - Stack Overflow

    Apr 28, 2017 · JavaScript replace part of string regex. 0. Replace part of a string using a regexp. 0. Regex to replace a ...

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

    You could also try this : function replaceStr(str, find, replace) { for (var i = 0; i < find.length; i++) { str = str.replace(new RegExp(find[i], 'gi'), replace[i ...

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

    An alternative non-regexp idiom for simple global string replace is: function string_replace(haystack, find, sub) { return haystack.split(find).join(sub); } This is preferable …

  8. Javascript replace all "%20" with a space - Stack Overflow

    Nov 21, 2016 · I'm surprised to see that this is the only answer not trying to actually replace things in the string. This is the proper way to handle this situation. – Corey Ogburn

  9. 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 ...

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

    Aug 10, 2016 · If the group is not in the match, or not in the regular expression, or if a string was passed as the first argument to replace instead of a regular expression, this resolves to a …

Refresh