ChrisB: RegExp Split \r\n in Javascript

Beitrag lesen

Hi,

warum liefert folgender Split in Javascript den Wert 7?

var test = "A\r\n\r\nB\r\nC\r\n";

return test.split(/(\r?\n)+/).length;

  
[MDC: string.split(\[separator\]\[, limit\])](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/split):  

> “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.”  
  
MfG ChrisB  
  

-- 
RGB is totally confusing - I mean, at least #C0FFEE should be brown, right?