Home > Web Front-end > JS Tutorial > body text

The replace function replaces individual and global usage methods

一个新手
Release: 2017-09-29 09:51:02
Original
1764 people have browsed it

//单个
var aa="1-2-3";
aa=aa.replace(',',".");
console.log(aa);
Copy after login

//Global replacement

var aa="1-2-3";
aa=aa.replace(/-/g,".");
console.log(aa);
Copy after login

##//Cut the content in the square bracket characters

var text ="hello [Word]";
var aaa=text.match(/([^\[\]]+)(?=\])/g)
console.log(aaa);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!