87,910
社区成员
发帖
与我相关
我的任务
分享
document.getElementsByTagName('html')[0].innerHTML.replace(/.+(<\/head>).+/g,'$1');
document.getElementsByTagName('html')[0].innerHTML.replace(/<head>.+<\/head>/g,"");
document.getElementsByTagName('html')[0].innerHTML.replace(/[\s\S]+(<\/head>)[\s\S]+/g,'$1');
要这么写,那是因为 . 号一般情况下是不匹配换行符的,所以你要用[\s\S]或[\d\D]这种写法来代替它去匹配所有字符