Yes, the /g flag is confusing, because the regular expression kind of turns into an iterator. I’d much prefer an actual iterator-based API that doesn’t mutate the regular expression.
On Jul 16, 2014, at 9:26 , Alex Vincent <ajvinc...@gmail.com> wrote: > r = /\u0020+$/g; p = r.exec(" "); q = r.exec(" "); JSON.stringify([p, q]) > // "[[\" \"],null]" > > Why does calling exec the second time generate null? When I try the regular > expression without the /g flag, I get: > // "[[\" \"],[\" \"]]" > > > > -- > "The first step in confirming there is a bug in someone else's work is > confirming there are no bugs in your own." > -- Alexander J. Vincent, June 30, 2001 > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss -- Dr. Axel Rauschmayer a...@rauschma.de rauschma.de
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss