Collected notes

Leftmost longest vs leftmost greedy

Both prioritize finding a match as early in the haystack as possible. Then, the second thing to consider is how long the match is. Given a choice in the matching (from e1|e2 or e* etc), the longest semantics picks choices such that the final match is the longest possible. For greedy, we pick choices such that will lead to the match the quickest.

Nullable quantifiers

If e can match the empty string, iterations of e{0,n} cannot match the empty string.

Capture reset

After each quantifier iteration, the values of all capture groups inside are reset to undefined. So /(?:(a)|b)*/ on “ab” will match the entirety of “ab”, but the group (a) will be undefined.

Backereferences to a group that did not match anything

Then the backreference matches the empty string. This applied to both backreferences to a group which did not match anything preceding the reference, and to a group following the reference.

To discuss

Action items