/* var str="<body class='ss'>1111</body><b>3333,</b>";
var html=/<(.|\n)+?>/ig;
console.log(str.replace(html,"")); */
/*
var str="<body class='ss'>1111</body><b>3333,</b>";
var html=/(<(.|\n)+?>)/ig;
console.log(str.replace(html,"$1"));
*/

/* var str="<body class='ss'>11可有可无sfsdfsd11</body><b>3333,</b>";
var html=/(<body(.|\n)+?>)/ig;
console.log(str.replace(html,"$1 <img src='xxxx'/>"));
*/


var str="<body class='ss'>11可有可无sfsdfsd11</body><b>3333,</b>";
var html=/(<body(.|\n)+?)>/ig;
console.log(str.replace(html,"$1 onclick='test()'>"))

 

https://codepen.io/jianyeruan/pen/pwxbEd

 posted on 2017-07-09 00:18  jayruan  阅读(156)  评论(0编辑  收藏  举报