想把 <code ... </code> 里的 < unescape 掉成 <,如何能做到?
比如字符串如下:
var str = `<pre><code class="lang-html"><style>
.myDiv {
width: 150px;
height: 200px;
background: red;
border-top-left-radius: 100%;
}
</style>
<div class="myDiv"></div>
</code></pre>
`
// 随便写的,无视之
str = str
.replace(/<code(.|\n|\t|\f|\r|\v)+?(<)(.|\n|\t|\f|\r|\v)+<\/code>/g, (a) => {
return ''
})
console.log(str)
另外,任意字符我是用 (.|\n|\t|\f|\r|\v) 去匹配,而 [.\n\t\f\r\v] 为何不行?
以上两个问题,求指导 ..
手掌心
米琪卡哇伊
随时随地看视频慕课网APP
相关分类