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

Non-minimal regex when adding a second range lower than the first #37

Closed
Seb35 opened this issue Jun 4, 2020 · 1 comment · Fixed by #38
Closed

Non-minimal regex when adding a second range lower than the first #37

Seb35 opened this issue Jun 4, 2020 · 1 comment · Fixed by #38

Comments

@Seb35
Copy link
Contributor

Seb35 commented Jun 4, 2020

With the specific following instructions, regenerate produces a non-minimal (but correct) regex:

regenerate().addRange( 99, 100 ).addRange( 65, 99 ).toString()
'[cdA-c]'

By switching the order, we have a correct minimal regex:

regenerate().addRange( 65, 99 ).addRange( 99, 100 ).toString()
'[A-d]'

Playing a bit with the boundaries, it seems it only occur when the end of the second range is exactly the same as the start of the first range.

@mathiasbynens
Copy link
Owner

Good catch. Looks like we have an off-by-one somewhere. Patches welcome!

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

Successfully merging a pull request may close this issue.

2 participants