想把 <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] 為何不行?以上兩個問題,求指導 ..
關于 javascript 正則替換指定條件字符串的兩個問題
手掌心
2018-12-19 18:15:28