<regex>: Make capture groups in negative lookahead assertions always match nothing by muellerj2 · Pull Request #5366 · microsoft/STL (original) (raw)

Fixes #5245 and completes #5269.

Changes compared to #5269:

The most important change -- which had already been applied in the second-to-last commit in #5269 -- is the assignment _Tgt_state = _St when a negative lookahead assertion is successful. This resets the state of all capture groups, so in particular it resets the state of those capture groups that were matched at some point while processing the negative lookahead assertion. Before, only the position in the input string was reset via _Tgt_state._Cur = _Cur. The same line can still be found in the code for positive lookahead assertions, but it's correct there: Capture group matches are meaningful for positive lookahead assertions and are to be retained according to the ECMAScript standard.