title: Replace tags with new tags with innerHTML to set to id
body: <p>I have the following text:</p>
  <pre><code>Send to &lt;a class=&quot;tipo9&quot; id=&quot;1&quot;&gt;Example Mark&lt;/a&gt; and &lt;a class=&quot;tipo0&quot; id=&quot;3&quot;&gt;Testing James&lt;/a&gt; a new Document
  </code></pre>
  <p>And would like to obtain the following code:</p>
  <pre><code>Send to &lt;per&gt;1&lt;/per&gt; and &lt;per&gt;3&lt;/per&gt; a new Document
  </code></pre>
  <p>The number between the  tags is the id number.</p>
  <p>I have found a very complicated solution like:</p>
  <pre><code>function convert(f) {
      var str=f;
      str=str.replaceAll('&lt;a class=&quot;', '[per]');
      str=str.replaceAll('/a&gt;', '[/per]');
      str=str.replaceAll(/tipo\d/g, '');
      str=str.replaceAll(/['&quot;]+/g, '');
      str=str.replaceAll('&quot;', '');
      str=str.replaceAll(' id=', '');
      str=str.replaceAll(/\s*\&gt;.*?\&lt;\s*/g, &quot;&quot;)
      str=str.replaceAll('[per]', '&lt;per&gt;');
      str=str.replaceAll('[/per]', '&lt;/per&gt;');
      str=str.trim();
      document.getElementById('testoHTML').value=str;
  }
  </code></pre>
  <p>but it gives different problems. I know that it should exist another solution with regex but I was not able to obtain a working result.</p>
  <p>Hope to find some good solution :)</p>