regex - how to change `&lt;` to `<` in a string only inside `code` tag using regexp with javascript? -


i want replace &lt; < in string only inside code tag (here point)

for example, here string:

<pre><code class="lang-html">&lt;style&gt;   .mydiv {     width: 150px;     height: 200px;     background: red;     border-top-left-radius: 100%;   } &lt;/style&gt; &lt;div class=&quot;mydiv&quot;&gt;&lt;/div&gt; </code></pre> 

but don't know how write exact regular expression.

i write down below:

var str = `<pre><code class="lang-html">&lt;style&gt;   .mydiv {     width: 150px;     height: 200px;     background: red;     border-top-left-radius: 100%;   } &lt;/style&gt; &lt;div class=&quot;mydiv&quot;&gt;&lt;/div&gt; </code></pre> `  str = str   .replace(/<code(.|\n|\t|\f|\r|\v)+?(&lt;)(.|\n|\t|\f|\r|\v)+<\/code>/g, (a) => {     return ''   })  console.log(str) 

the regular expression can match string, don't how next.

one more question, (.|\n|\t|\f|\r|\v)+? work, [.\n\t\f\r\v] not work, why?

thanks in advance!


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -