title: Split string with replace by multiple tags function
body: <p>My string has HTML code. I need to split it to array by <strong>br</strong> and <strong>strong</strong> tags. Example of string:</p>
  <p><code>string = &quot;&lt;strong&gt;There was once upon a time a king&lt;/strong&gt; but where he reigned and what he was called, I do not know.&lt;br&gt;Then it was foretold to the king that his daughter would find her health by &lt;strong&gt;eating an apple.&lt;/strong&gt;&lt;br&gt;So he ordered it to be proclaimed throughout the whole of his kingdom...&quot;;</code></p>
  <p>Is it possible to identify splitting tag and:</p>
  <ol>
  <li>If tag is <strong>br</strong> then add &quot;\n&quot; to the end of that part.</li>
  <li>If tag is <strong>strong</strong> then add &quot;[b]&quot; to the beginning of that part.</li>
  </ol>
  <p>So this is what I want to achieve:</p>
  <pre><code>&quot;[b]There was once upon a time a king&quot;,
   &quot;but where he reigned and what he was called, I do not know. \n&quot;,
   &quot;Then it was foretold to the king that his daughter would find her health by &quot;,
   &quot;[b]eating an apple. \n&quot;,
   &quot;So he ordered it to be proclaimed throughout the whole of his kingdom...&quot;
  </code></pre>
  <p>I have tried</p>
  <pre><code> var array = string.replace(/(&lt;strong\b[^&gt;]*&gt;(.*?)&lt;\/strong&gt;)|(&lt;br&gt;)/g,function(string,p1,p2) {
      if(p1) return '[b]$1';
      if(p2) return ' \n';
  });
  </code></pre>
  <p>but that did not help me.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>string = "&lt;strong&gt;There was once upon a time a king&lt;/strong&gt; but where he reigned and what he was called, I do not know.&lt;br&gt;Then it was foretold to the king that his daughter would find her health by &lt;strong&gt;eating an apple.&lt;/strong&gt;&lt;br&gt;So he ordered it to be proclaimed throughout the whole of his kingdom...";
  var array = string.replace(/(&lt;strong\b[^&gt;]*&gt;(.*?)&lt;\/strong&gt;)|(&lt;br&gt;)/g,function(string,p1,p2) {
          if(p1) return '[b]$1';
          if(p2) return ' \n';
      });
  
  console.log(array);</code></pre>
  </div>
  </div>
  </p>