js如何解析html
后台返回给前台如下html字符串内容
<pre style="word-wrap: break-word; white-space: pre-wrap;">str</pre>
前台JS代码如何解析出str的内容? html js 字符串 解析
[解决办法]
var str = '<pre style="word-wrap: break-word; white-space: pre-wrap;">str</pre>';
var reg = /\<[^\>]*\>([^\<]*)\<[^\>]*\>/g;
var a = str.replace(reg,function($0,$1){return $1;});
console.log(a);