会打代码的扫地王大爷
2016-05-10 12:18js RegExp不能匹配空格和换行吗
<div>关于我们
<div class="showtab">
<div class="content">
<div class="one">
.....
用下面的js去匹配匹配不到
function replaceAll(obj ,oldStr, newStr)
{
return obj.replace(new RegExp(">[\s]*"+oldStr+"[\s]*<","gm"),function(word) {
// console.log(word);
return ">"+newStr+"<"}
);
}
下面这段就可以了
return obj.replace(/>[\s]*关于我们[\s]*</gm, "><");
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- js RegExp不能匹配空格和换行吗
- 1个回答