Horje
replaceAll alternative with string value javascript Code Example
replaceAll alternative with string value javascript
function replaceAll(str, find, replace) {
    var escapedFind=find.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
    return str.replace(new RegExp(escapedFind, 'g'), replace);
}
//usage example
var sentence="How many shots did Bill take last night? That Bill is so crazy!";
var blameSusan=replaceAll(sentence,"Bill","Susan"); 




Javascript

Related
js replace all Code Example js replace all Code Example
include gif in react Code Example include gif in react Code Example
event listener javascript Code Example event listener javascript Code Example
angular serve on different port Code Example angular serve on different port Code Example
get element by tag name Code Example get element by tag name Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6