Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
מדוע
var text = 'abababab'; text.split(/(a)/g ) = ["b", "a", "b", "a", "b", "a", "b", "a", "b"]
לעומת
var text = 'abababab'; text.split(/a/g ) = ["b", "b", "b", "b", "b"]
כתוב פה:
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.
separator
אגב, הדגל g לא משנה כלום במקרה של split, בכל מקרה הוא עובר על כל ההתאמות עד סוף המחרוזת.