Not really. An advanced alternative regex library for JavaScript is XRegExp, but it doesn't have the feature you're after - not even as an addon.
A simpler regex feature that is supported by XRegExp is named capture groups, so you can write:
var days = XRegExp('(?:(?<d>Sat)ur|(?<d>Sun))day', 'gi');
You can't use numbers as group names, but named groups should fit what your needs - they allow backreferences (using \k<d>
), replacement (${d}
), capturing (match.d
), and all features of a regular numbered group.
Named captured groups is supported natively by ES2018: ES2018 Regular Expression Updates.
According to node.green, named capture groups are supported by Node.js ≥10.3.0, or by ≥8.6.0 with the --harmony
flag.