AW: 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](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/split)[, limit])]:  
> > “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  
>   
>   
  
ok danke. dann macht das Sinn :)