Home >Web Front-end >JS Tutorial >The replace function replaces individual and global usage methods
//单个 var aa="1-2-3"; aa=aa.replace(',',"."); console.log(aa);
//Global replacement
var aa="1-2-3"; aa=aa.replace(/-/g,"."); console.log(aa);##//Cut the content in the square bracket characters
var text ="hello [Word]"; var aaa=text.match(/([^\[\]]+)(?=\])/g) console.log(aaa);
The above is the detailed content of The replace function replaces individual and global usage methods. For more information, please follow other related articles on the PHP Chinese website!