title: JavaScript split() adding extra item to array in Firefox/IE only
body: <p>I'm trying to understand the behaviour of different browsers with the JavaScript split() method, matching by linefeed (\n) regexp.</p>
  
  <p>I have a <em>textarea</em> input form which is to take rows pasted from Excel and split them by linefeed into an array:</p>
  
  <pre><code>var rowsplit = document.getElementById("inputfield").value.split(/\n/g);
  </code></pre>
  
  <p>The user selects the rows in Excel by the side bar and so the first 11 columns have data and there are a whole bunch of empty columns after those to the edge of the spreadsheet that I slice() out later. So a typical input from Excel would be:</p>
  
  <pre><code>[data][data][data][data]x11[null][null][null]etc until edge of spreadsheet
  </code></pre>
  
  <p>The difference is what is matched by the regexp and pushed into the array.</p>
  
  <p>In both Chrome 28 and Safari 5.1, when selecting three rows of information, it correctly matches the \n as 3, outputs them to the array and goes frolicking through a daisy field without a care in the world.</p>
  
  <p>In IE10 and Firefox 19 though, it matches the first three linefeeds fine and then pulls an extra one which is blank. So the \n expression splits it into <em>four</em> items, crashes into a building and kills hundreds.</p>
  
  <p>I have read a lot about different browsers handling the CRLF characters differently and tried splitting by \r\n and just \r but it seems to introduce more trouble. I also copied the Excel rows into Notepad++ and turned on visibility of the CRLF characters to see that there only appears to be 3, so why are IE and Firefox adding another one?</p>
  
  <p>I've also read a lot about the pains people have with regexp, JS, browsers, line breaks AND Excel but most of it seems to be more relevant to older browsers so I was hoping someone with knowledge on the current state of things could provide some insight.</p>
  
  <p>Thanks!</p>