replace all character in string 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"); str = str.replace(/abc/g, '');let a = "How to search and replace a char in a string";
while (a.search(" ", ""))
{
a = a.replace(" ", "");
}
console.log(a);str.split(search).join(replacement);
Also in JavaScript:
- vuejs pass all events to child
- okhttp3 application/json get kotlin
- javascript download file
- expo build apk
- react createelement
- disable input field with jquery
- expo update react native
- get div text jquery
- how to pad string js
- store the text from a form jquery
- round off value in javascript
- how to import dotenv in react
- append data in value array javascript
- nextjs router get complete url
- how to get text which is in input td using jquery
- js array clone
- <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'/>
- discord.js remove every role a user has
- smtpjs cdn
- computed setter
- validatorjs number
- js detect end of array
- discord function promise
- jquery basic authenticated get user