<head>
<title>hello world</title>
<meta content="width=device-width, initial-scale=0.5, maximum-scale=1.0, user-scalable=no" name="viewport">
</head>
我希望有人可以帮助我,我不熟悉正则表达式
答案 0 :(得分:0)
答案 1 :(得分:0)
可能你可以这样做;
var htmlText = "<head><title>hello world</title><meta content="width=device-width, initial-scale=0.5, maximum-scale=1.0, user-scalable=no" name="viewport"></head>";
inner = htmlText.replace(/<head>(.+)<\/head>/,"$1");
<head>(.+)<\/head>