Closed isaacwein closed 11 months ago
after all i test it in a go playground https://go.dev/play/p/Rg4s_Q4kJr5 https://go.dev/play/p/HudPpY5p4AE sorry if I didn't do it in the beginning and it actually works like that in Go if so or I missing something in regular expressions or its a bug in Go 🫢
i tried to Reproduce it like this https://go.dev/play/p/Rg4s_Q4kJr5 and it didnt have the same bug
i think this issue should be changed to a Question label rather then a bug
Your problem is [\w.-_]
as you have created a character range. Escape the dash \-
and it should work as expected.
In the future, please take these questions either on Discord or IRC.
Thank you I didn't realize that a dash is a reserved character for a character class thank
Bug Description
. (dot) in a Character class capturing all
Reproduction steps
golang regex
`^(https?://)?([\w.-_]+\.)?xyz\.com(?:\:\d{2,5})?$`gm
match tohtp://aa.xyz.com
it should only match to http://aa.xyz.comExpected Outcome
it shouldn't match but its matches it looks like the dot thinks that it should capture all but a dot in a Character class is not a wildcard if i would change the regular expiration to
`^(https?://)?([\w-_.]+\.)?xyz\.com(?:\:\d{2,5})?$`gm
the . to the lest in the Character class it would work as ExpectedBrowser
115.0.5790.110 (Official Build) (64-bit) (cohort: Stable)
OS
Microsoft Windows 11 Version 22H2 (0S Build 22621.2070)
how it is![image](https://github.com/firasdib/Regex101/assets/34663972/c7ffcee5-59df-4afd-8b58-34696b2fceb4)
how it should be![image](https://github.com/firasdib/Regex101/assets/34663972/ab97d65c-7f17-4822-add7-144d9a41d1ce)