🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Errors › Requires_global_RegExp
TypeError: matchAll/replaceAll must be called with a global RegExp - JavaScript | MDN
July 8, 2025 - The JavaScript exception "TypeError: matchAll/replaceAll must be called with a global RegExp" occurs when the String.prototype.matchAll() or String.prototype.replaceAll() method is used with a RegExp object that does not have the global flag set. TypeError: String.prototype.matchAll called ...
🌐
DeepScan
deepscan.io › docs › rules › bad-replace-all-arg
String.prototype.replaceAll() should not be called with a ...
This rule applies when a regular expression without the global flag (g) is used at String.prototype.replaceAll().
🌐
Designcise
designcise.com › web › tutorial › how-to-fix-string-prototype-replaceall-called-with-a-non-global-regexp-argument-javascript-error
How to Fix "replaceAll called with a non-global RegExp argument" JavaScript Error? - Designcise
January 4, 2024 - When you use a regular expression ... // ... The reason this happens is that the global flag is required when using a regular expression with String.prototype.replaceAll(). Omitting the global flag results in a TypeError, ...
🌐
GitHub
github.com › eslint › eslint › issues › 15073
New Rule: require global regular expression to be used with `replaceAll` · Issue #15073 · eslint/eslint
September 16, 2021 - This rule should require that regular expressions passed as the first argument to replaceAll are global. String.prototype.replaceAll: https://github.com/tc39/proposal-string-replaceall · Warns about a potential problem · `abc`.replaceAll(/a/, ...
Author: eslint
🌐
GitHub
github.com › tc39 › proposal-string-replaceall › issues › 16
How should replaceAll behave if searchValue is a non-global RegExp? · Issue #16 · tc39/proposal-string-replaceall
March 21, 2019 - Related to, but different from #8. #8 wants it to auto-convert a non-global regex to a global regex. I think we should accept regex searchValues, but not convert them to a global regex. String.p.matchAll is setting precedent for "all" me...
Author: tc39
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › replaceAll
String.prototype.replaceAll() - JavaScript - MDN Web Docs
The replacement has the same semantics as that of String.prototype.replace(). A new string, with all matches of a pattern replaced by a replacement. ... Thrown if the pattern is a regex that does not have the global (g) flag set (its flags property does not contain "g").
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › replaceall
String replaceAll() in JavaScript - Mastering JS
March 21, 2022 - Only cruel people thrive here.'; sentence.replaceAll(/cruel/ig, 'wonderful'); // The world is a wonderful place. Only wonderful people thrive here. // TypeError: String.prototype.replaceAll called with a non-global RegExp argument sentence.replaceAll(/cruel/i, 'wonderful');
🌐
Medium
medium.com › nerd-for-tech › basics-of-javascript-string-replaceall-method-e53b0ce22a92
Basics of Javascript · String · replaceAll() (method) | by Jakub Korch | Medium
June 17, 2021 - try { let re = /(\w+)\s(\w+)/; let fullName = 'John Smith'; let newstr = fullName.replaceAll(re, '$2, $1'); console.log(newstr); // Smith, John } catch(err){ console.log(err); }// OUTPUT: // TypeError: String.prototype.replaceAll called with a non-global // RegExp argument at String.replaceAll (<anonymous>)try { let re = /(\w+)\s(\w+)/g; let fullName = 'John Smith'; let newstr = fullName.replaceAll(re, '$2, $1'); console.log(newstr); // Smith, John } catch(err){ console.log(err); }// OUTPUT: // Smith, John
🌐
Medium
medium.com › geekculture › replaceall-in-javascript-b61f4e94f028
replaceAll in JavaScript
June 28, 2021 - The Mathias bynens proposal solves these problems and gives a very easy way to do substring replacement using `replaceAll()` which replaces all instances of a substring in a string with another string value without using a global regexp.
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › javascript-replaceall-replace-all-instances-of-a-string-in-js
JavaScript replaceAll() – Replace All Instances of a String in JS
July 28, 2022 - const my_string = "I like dogs because dogs are adorable!"; let pattern = /dogs/; let replacement = "cats"; let my_new_string = my_string.replaceAll(pattern,replacement); console.log(my_new_string); // output // test.js:6 Uncaught TypeError: String.prototype.replaceAll called with a // non-global RegExp argument // at String.replaceAll (<anonymous>) // at test.js:6:31 ·
🌐
RPG Maker Forums
forums.rpgmakerweb.com › home › game development engines › legacy engine support › rpg maker mv support
rpg maker mv - TypeError: String.prototype.replaceAll called with a non-global RegExp argument | RPG Maker Forums
April 17, 2022 - String.prototype.replaceAll = function (search_string, replace_string) { console.log("String.replaceAll made by RETRO"); return this.split(search_string).join(replace_string) }; (save changes >> deploy (make sure retro.js isn't loaded from cache). Then you can check console log if that polyfill is used for String.replaceAll If "String.replaceAll made by RETRO" won't appear in log it means something is overriding that method.
🌐
V8
v8.dev › features › string-replaceall
String.prototype.replaceAll · V8
November 11, 2019 - For consistency with the pre-existing ... while String#replaceAll replaces all occurrences. If searchValue is a non-global RegExp, then String#replace replaces only a single match, similar to how it behaves for strings....
🌐
Proposals
proposals.es › proposals › String.prototype.replaceAll
String.prototype.replaceAll proposal
Currently there is no way to replace all instances of a substring in a string without use of a global regexp. String.prototype.replace only affects the first occurrence when used with a string argument.
🌐
DeepScan
deepscan.io › docs › rules › bad-match-all-arg
String.prototype.matchAll() should be called with a global ...
This rule applies when a regular expression without the global flag (g) is used at String.prototype.matchAll().
🌐
RPG Maker Forums
forums.rpgmakerweb.com › home
RPG Maker Forums
April 17, 2022 - Post here if you have specific ideas or a game prototype that you want people to try out!
🌐
GitHub
github.com › mdn › content › blob › main › files › en-us › web › javascript › reference › errors › requires_global_regexp › index.md
content/files/en-us/web/javascript/reference/errors/requires_global_regexp/index.md at main · mdn/content
The JavaScript exception "TypeError: ... RegExp" occurs when the {{jsxref("String.prototype.matchAll()")}} or {{jsxref("String.prototype.replaceAll()")}} method is used with a {{jsxref("RegExp")}} object that does not have the {{jsxref("RegExp/global", "global")}} flag set...
Author: mdn
🌐
Xah Lee
xahlee.info › js › js_String.prototype.matchAll.html
JS: String.prototype.matchAll
If the argument is a regex object, it must have the regex flag g, else its error. // the regex object should have flag g // "year 1999".matchAll(/\d{4}/) // error: Uncaught TypeError: String.prototype.matchAll called with a non-global RegExp argument
🌐
WebKit
bugs.webkit.org › show_bug.cgi
202471 – Implement String.prototype.replaceAll
WebKit Bugzilla · Browse · Search+ · Log In · Top of Page · Format For Printing · Clone This Bug · Reports
🌐
Reality Ripple
udn.realityripple.com › docs › Web › JavaScript › Reference › Global_Objects › String › replaceAll
String.prototype.replaceAll() - JavaScript
(The exact number of arguments depends on whether the first argument is a RegExp object—and, if so, how many parenthesized submatches it specifies.) ... When using a regular expression search value, it must be global. This won't work: 'aabbcc'.replaceAll(/b/, '.'); TypeError: replaceAll must be called with a global RegExp