ES2021 was just approved and is finally, FINALLY shipping with String.prototype.replaceAll. So
'falafel'.replace(/l/g,'b')
'falafel'.replaceAll('l','b')
both give you `fabafeb`.
No more regex needed just to get the "greedy" flag in there!
ES2021 was just approved and is finally, FINALLY shipping with String.prototype.replaceAll. So 'falafel'.replace(/l/g,'b') both give you `fabafeb`. No more regex needed just to get the "greedy" flag in there! 7 comments
@meena I think it's already there and we just have some very bad habits ingrained (and lots of very common dependencies don't use the new JS syntax themselves, so then THEY install those dependencies even if you don't) @darius 1. Nice! Shouldn't need a regex just for that. |
@darius thanks, now I want fabafeb for dinner