firasdib / Regex101

This repository is currently only used for issue tracking for www.regex101.com
3.26k stars 199 forks source link

Valid Java 8 regex is not accepted #2080

Closed karl-riley closed 1 year ago

karl-riley commented 1 year ago

Bug Description

When providing a valid Java 8 regex for email validation and selecting 'Java 8', regex101.com rejects it with the following error message printed twice: "- You cannot create character ranges with the terminating character class token"

Reproduction steps

Select 'Java 8' on left-hand menu Enter this regex: ^[a-zA-Z0-9_!#$%&’*+/=?`{|}~^.-]+@[a-zA-Z0-9.-]+$ Enter this test string: username@domain.co.in

Regex matches test string with actual Java code, and can also be validated here https://www.freeformatter.com/java-regex-tester.html

Expected Outcome

Matched

Browser

Chrome on Windows 11, 114.0.5735.110 (Official Build) (64-bit)

OS

Windows 11

working-name commented 1 year ago

Hello @karl-riley

Could you please share a regex101.com link? I cannot seem to reproduce the problem.

karl-riley commented 1 year ago

https://regex101.com/r/IQvDN9/1

Also a screenshot: [image: image.png]

On Mon, Jun 12, 2023 at 11:31 AM Alan @.***> wrote:

Hello @karl-riley https://github.com/karl-riley

Could you please share a regex101.com link? I cannot seem to reproduce the problem.

— Reply to this email directly, view it on GitHub https://github.com/firasdib/Regex101/issues/2080#issuecomment-1587575933, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC5DOFNMAGQDMRWHZ46E35DXK4Y47ANCNFSM6AAAAAAZDQI44M . You are receiving this because you were mentioned.Message ID: @.***>

working-name commented 1 year ago

@karl-riley Thank you for that!

It seems java is ok with - at the end of a character class, including java 8 (Java(TM) SE Runtime Environment (build 1.8.0_161-b12)). That being said, I don't actually know Java so take what I say with a grain of salt :)

As a workaround for now, try including the - in the beginning of a character class instead: https://regex101.com/r/IQvDN9/2

We'll look into it.

firasdib commented 1 year ago

I can see there is a clear case to handle this in the code, but I don't know why. I'll have to investigate this a little bit further.

firasdib commented 1 year ago

I'll have this resolved in the next release.