JavaScript split string with .match(regex) : <p>From the Mozilla Developer Network for function <code>split()</code>:</p>

<blockquote>
  <p>The split() method returns the new array.</p>
  
  <p>When found, separator is removed from the string and the substrings
  are returned in an array. If separator is not found or is omitted, the
  array contains one element consisting of the entire string. If
  separator is an empty string, str is converted to an array of
  characters.</p>
  
  <p>If separator is a regular expression that contains capturing
  parentheses, then each time separator is matched, the results
  (including any undefined results) of the capturing parentheses are
  spliced into the output array. However, not all browsers support this
  capability.</p>
</blockquote>

<p>Take the following example:</p>

<pre><code>var string1 = 'one, two, three, four';
var splitString1 = string1.split(', ');
console.log(splitString1); // Outputs ["one", "two", "three", "four"]
</code></pre>

<p>This is a really clean approach. I tried the same with a regular expression and a somewhat different string:</p>

<pre><code>var string2 = 'one split two split three split four';
var splitString2 = string2.split(/\ split\ /);
console.log(splitString2); // Outputs ["one", "two", "three", "four"]
</code></pre>

<p>This works just as well as the first example. In the following example, I have altered the string once more, with 3 different delimiters:</p>

<pre><code>var string3 = 'one split two splat three splot four';
var splitString3 = string3.split(/\ split\ |\ splat\ |\ splot\ /);
console.log(splitString3); // Outputs ["one", "two", "three", "four"]
</code></pre>

<p>However, the regular expression gets relatively messy right now. I can group the different delimiters, however the result will then include these delimiters:</p>

<pre><code>var string4 = 'one split two splat three splot four';
var splitString4 = string4.split(/\ (split|splat|splot)\ /);
console.log(splitString4); // Outputs ["one", "split", "two", "splat", "three", "splot", "four"]
</code></pre>

<p>So I tried removing the spaces from the regular expression while leaving the group, without much avail:</p>

<pre><code>var string5 = 'one split two splat three splot four';
var splitString5 = string5.split(/(split|splat|splot)/);
console.log(splitString5);
</code></pre>

<p>Although, when I remove the parentheses in the regular expression, the delimiter is gone in the split string:</p>

<pre><code>var string6 = 'one split two splat three splot four';
var splitString6 = string6.split(/split|splat|splot/);
console.log(splitString6); // Outputs ["one ", " two ", " three ", " four"]
</code></pre>

<p>An alternative would be to use <code>match()</code> to filter out the delimiters, except I don't really understand how reverse lookaheads work:</p>

<pre><code>var string7 = 'one split two split three split four';
var splitString7 = string7.match(/((?!split).)*/g);
console.log(splitString7); // Outputs ["one ", "", "plit two ", "", "plit three ", "", "plit four", ""]
</code></pre>

<p>It doesn't match the whole word to begin with. And to be honest, I don't even know what's going on here exactly.</p>

<hr>

<p>How do I properly split a string using regular expressions without having the delimiter in my result?</p>
