You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The plugin works for RegExp literals but not for regular expressions created via new RegExp().
Describe the solution you'd like
FWIW: I created the following (quick and very dirty) workaround: I replace new RegExp with new RegExpX – which invokes the class shown below. The solution I’d like would be cleaner than that.
classRegExpX{constructor(str,flags){constRE=/(?<!\\)\((\?<(?<name>[^<>]+)>)?/g;letparenCounter=0;constgroupNameToGroupNumbers=newMap();str=str.replaceAll(RE,(all, ...args)=>{constgroups=args.pop();parenCounter++;if(groups.name){letgroupNumbers=groupNameToGroupNumbers.get(groups.name);if(groupNumbers===undefined){groupNumbers=[];groupNameToGroupNumbers.set(groups.name,groupNumbers);}groupNumbers.push(parenCounter);// It’s in the Map, only its group number matters nowreturn`(`;// avoid any name clashes}returnall;});// Override what the constructor would normally return:return_wrapRegExp(newRegExp(str,flags),Object.fromEntries(groupNameToGroupNumbers));}}
Describe alternatives you've considered
None
Documentation, Adoption, Migration Strategy
No response
The text was updated successfully, but these errors were encountered:
Hey @rauschma! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.
💻
What problem are you trying to solve?
The plugin works for RegExp literals but not for regular expressions created via
new RegExp()
.Describe the solution you'd like
FWIW: I created the following (quick and very dirty) workaround: I replace
new RegExp
withnew RegExpX
– which invokes the class shown below. The solution I’d like would be cleaner than that.Describe alternatives you've considered
None
Documentation, Adoption, Migration Strategy
No response
The text was updated successfully, but these errors were encountered: