我想用正则获取下面里面的里的信息,我的正则表达式该怎么写呀?_百度知 ...
发布网友
发布时间:2024-10-21 02:08
我来回答
共1个回答
热心网友
时间:2024-11-04 14:24
var reg = /<dl[^>]+class[=\"\']+book_list[\"\'][^>]*>((?:(?!\/dl>)[\d\D])*)<\/dl>/gi;
var html = '<ul id="book_date">\r\n <li>\r\n <dl class="book_list">\r\n <dt>1</dt>\r\n <dd><a target="_blank" href="http://weibo.com/p/100202read8358222">人性中的善良天使</a></dd>\r\n <dd>[美]斯蒂芬·平克</dd>\r\n <dd>中信出版社</dd>\r\n </dl>\r\n </li>\r\n</ul>';
var tmp = html.match(reg)[0];
console.log(tmp);
var r = /<(d(t|d))[^>]*>((?:(?!<\/\1>)[\s\S])*)<\/\1>/gi;
while (r.exec(tmp)) {
console.log(RegExp.$3);
}