Home > Web Front-end > JS Tutorial > JavaScript string replacement and string splitting sample code_javascript skills

JavaScript string replacement and string splitting sample code_javascript skills

WBOY
Release: 2016-05-16 17:09:28
Original
978 people have browsed it

JS (JavaScript) string replacement function (a bit like PHP's preg_replace)

str.replace('xxx', 'yyyy'); Replace the first
str.replace(/xxx/g, 'yyyy'); Replace all

string splitting (similar to PHP's splitting function)

Copy code Code As follows:

var test = 'a-b-c-d';
test.split('-');
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