Pop named regexp captures off the stack to avoid unbalanced stack

Fixes #2482