Skip to content

MAJOR BUG: Numbers are Matched as Characters #1252

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

Closed
nokernelspace opened this issue Feb 11, 2025 · 4 comments
Closed

MAJOR BUG: Numbers are Matched as Characters #1252

nokernelspace opened this issue Feb 11, 2025 · 4 comments
Labels

Comments

@nokernelspace
Copy link

What version of regex are you using?

1.11.1

Describe the bug at a high level.

[A-Za-z]* matches with numbers [0-9]

What are the steps to reproduce the behavior?

    let ret = Regex::new(r"([A-Za-z]*)").unwrap().is_match("1");
    println!("{:?}", ret);

What is the actual behavior?

true

What is the expected behavior?

false

@nokernelspace
Copy link
Author

Please fix, I need this for my lever.

@BurntSushi
Copy link
Member

It's not a bug. It's correct. Your regex matches the empty string and every string, including the empty string, contains the empty string.

@BurntSushi BurntSushi closed this as not planned Won't fix, can't repro, duplicate, stale Feb 11, 2025
@nokernelspace
Copy link
Author

https://regexr.com

is wrong do not use

@BurntSushi
Copy link
Member

You are incorrect, there is no empty string. Try it on any other regex parser

TIL that I don't understand strings. Lol. But no, you are definitively wrong. The string 1 has two different valid spans that correspond to the empty string: &s[0..0] and &s[1..1].

And regexr is correct. If you click "Details," it shows the matches. What it doesn't do is highlight empty matches. That's poor UI. https://regex101.com/ will highlight empty matches. And regex101 supports the dialect of regex implemented by this crate, where as regexr doesn't.

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

No branches or pull requests

2 participants