DEV Community

Discussion on: My RegExp nightmare

Collapse
 
luqman10 profile image
Abdul Qadir Luqman

What do you use in place of regex?

Collapse
 
nektro profile image
Meghan (she/her)

You can implement a replaceAll function for Strings just using the built-in replace and regex:

String.prototype.replaceAll = function(search, replacement) {
    return this.replace(new RegExp(search, 'g'), replacement);
}