Closed chrisdavidmills closed 3 years ago
I think a few more changes would make sense:
/g
global flag in the replaceAll
example is redundant as global search is what replaceAll
is all about.Hope you don't mind me chiming in :)
If you think all this makes sense, please assign to me
Assigned; cheers @MendyBerger !
Turns out that my point about replaceAll
together with /g
being redundant is wrong
Think this is resolved now
@185driver commented on Fri Dec 11 2020
Content Issue
URL of page you are seeing the problem on:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
Details
In line 3 of the JavaScript Demo near the top of the page, the regex code line is
const regex = /dog/gi;
. I would suggest that given the page relates to thereplace
method (and notreplaceAll
), the regex global flag should be removed to readconst regex = /dog/i;
. Doing so would provide a consistent expected output result for both examples.I think the usefulness of this small change becomes more apparent after comparing this page with the
replaceAll
method here. The use of the regex global flag seems more appropriate in the latter than in the former.Thanks for considering.