javascript字符串替换及字符串分割示例代码
发布时间:2016-12-30 来源:查字典编辑
摘要:JS(JavaScript)字符串替换函数(有点像PHP的preg_replace)str.replace(‘xxx',‘yyyy');替换...
JS(JavaScript)字符串替换函数(有点像PHP的preg_replace)
str.replace(‘xxx', ‘yyyy'); 替换第一个
str.replace(/xxx/g, ‘yyyy'); 替换全部
字符串分割(类似PHP的分割函数)
复制代码 代码如下:
var test = ‘a-b-c-d';
test.split(‘-');