js replace all symbols in string
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");
Also in JavaScript:
- same name different extentions react-native android
- require is not defined javascript
- ionic react use yarn
- how to create scroll to top button in reactjs example code
- Error: It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.
- nuxtjs http multiple proxy
- js run html in blob
- js array find
- how to run different node app on server different domains
- select input by name javascript
- javascript sessionStorage
- html shortcuts in jsx
- Warning: Failed child context type: Invalid child context `virtualizedCell.cellKey` of type
- javascript filter array of objects by key
- arrow function javascript
- jquery get the parent node
- passing data variable using ajax
- how to eat beans in javascirpt
- javascript dom methods list
- js reload page 1024 breakpoint
- javascript increment
- javascript convert number to binary representation
- sqrt javascript
- post json in flutter