Usually when you do something like 'test'.match(/(e)/) you would receive an array ['e', 'e'], where the first element is the match itself and the second from the selector (braces), but when using the global modifier as in 'test'.match(/(e)/g) it will omit the match, while it doesn’t in case I don’t use selectors at all.
I wonder if and where the following behavior is specified (using Chromium for this test).
http://msdn.microsoft.com/en-us/library/ie/7df7sf4x(v=vs.94).aspx
In other words, when
gis provided,matchcollects only topmost matches, ignoring any capturing groups.Example:
There’s no built-in that would collect all groups from all matches, like python
findalldoes, but it’s easy to write usingexec:Result: