title: Javascript - Split a string based on a character but retain it in the resulting array
body: <p><strong>Input</strong> </p>
  
  <pre><code>((Sass and Javascript) or (Python and Scala))
  </code></pre>
  
  <p><strong>Delimiters</strong> -"(" and ")"</p>
  
  <p><strong>Output</strong> is an Array with the delimiters present as elements</p>
  
  <pre><code>["(","(","Sass and Javascript",")","or","(","Python and Scala",")",")"]
  </code></pre>
  
  <p>The problem that I am facing is this. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var arr = "((Sass and Javascript) or (Python and Scala))".split(/[(|)]/);
  console.log(arr);
  document.getElementById("output").innerHTML = arr;</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="output"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>When I use <strong>split</strong> on the string, I am losing the "(" and ")" characters and since they might occur anywhere in the string, I will need to insert them into the Array manually. Is there a better way to do this in JS?</p>