How does the js regular match the content in <pre><code>xxx&lt;/code</pre>

"

first


console.log(1);

second


console.log(2);
"

want to extract the contents of pre > code and replace them

these are all strings, not dom

Feb.28,2021

provide an irregular way

if it is jq

var html="
console.log(1);
"; Console.log ($(html). Text ());

if you have to use js

var textEle=document.createElement("div");
textEle.innerHTML="<span></span>";
console.log(textEle.innerText);

var html="
console.log(1);
console.log(2);
"; Html.replace (/
(.*?)<\/code><\/pre>/g, "$1");

if there is a regular match, that's it

let str = `
  

console.log(1);

second

console.log(2);
`; Str.match (/ (? < =
)[\s\S]*?(?=<\/code><\/pre>)/gi);  // 

str.replace(/(?<=
)[\s\S]*?(?=<\/code><\/pre>)/gi, 'asdf');  // 
)

where / (? < = somePattern) / is "zero width positive review assertion" < del > thief Kiel length < / del >, / (? = somePattern) / is "zero width positive prediction advance assertion" < del > thief Kiel length * 2 < / del >, / somePattern/g is a global match, / somePattern/i is case insensitive, / somePattern*?/

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c122-2c311.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c122-2c311.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?