JSFiddle - React, Tailwind, and code Playground

JavaScript

var text = 'Some text...<div class=example><pre><ul><li>Item</li></ul></pre><div class=showExample></div></div>Some text...';
match = text.match(/<pre>(.*?)<\/pre>/)[1];
match = match.replace(/</g, '&lt;').replace(/>/g, '&gt;');
text = text.replace(/<pre>.*?<\/pre>/, '<pre>'+match+'</pre>');
alert(text);