Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Group when using a (?(DEFINE) , or using a (?&myexp) #329

Closed
freddieventura opened this issue Jun 3, 2021 · 2 comments
Closed

Comments

@freddieventura
Copy link

Hi,
First of srry for my brevity but I have tendinitis so Im just writting with one hand.
Due to this tendinitis I wanted to get the maximum off my keystrokes by using a PCRE compliant , Regexp library in JS , so I can use DEFINES and linebreaks in the RegExp such as https://stackoverflow.com/questions/36125759/pcre-define-statement-for-lookarounds#36130814

I'm happy so far using your libary , but I have invalid group when attempting to use define , or the Macros for groups (?<mygroup>)(?&mygroup)

console.log(XRegExp.exec('a',XRegExp('(?(DEFINE)(?<myexp1>a))(?&myexp1)')));
console.log(XRegExp.exec('a',XRegExp('(?<myexp1>a){0}(?&myexp1)')));

none of them are working.
If you dont offer such a functionality It would be nice if you include it so we can get closer to PCRE on JS.

Thank you,

@slevithan
Copy link
Owner

XRegExp already supports linebreaks via flag x, like PCRE. It does not support DEFINE blocks and subpattern reuse via (?&name), but there is an existing issue at #190 covering those (which also describes how they might be implemented).

I don't expect to get to implementing this since it would require substantial changes to the core of XRegExp regex generation and translation into native JS regex syntax. But pull requests are welcome.

@slevithan
Copy link
Owner

Also note that most of the use cases for DEFINE blocks and subpattern reuse are already enabled by XRegExp.build and XRegExp.tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants