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

Bug: .{0,99} and .* give different results, even without long lines in content #176

Closed
jorendorff opened this issue May 19, 2023 · 1 comment

Comments

@jorendorff
Copy link

jorendorff commented May 19, 2023

Steps to reproduce:

  1. Add the unit test below to onig/lib.rs, inside the tests module.
  2. cargo test test_space_star_dot_star
    #[test]
    fn test_space_star_dot_star() {
        let re1 = Regex::new(r"^\s*B\n\s*M\s*.{0,99}\R").unwrap();
        let re2 = Regex::new(r"^\s*B\n\s*M\s*.*\R").unwrap();
        let content = "B\n  M;\n";
        assert!(re1.find(content).is_some()); // passes
        assert!(re2.find(content).is_some()); // fails
    }

I think both regexes should match. But re1 succeeds and re2 fails!

Doing cd onig_sys/oniguruma && git checkout master && git pull origin master did not change the behavior.

Ruby 3.0.5p211 does not have this bug. Both regexes match:

re1 = /^\s*B\n\s*M\s*.{0,99}\R/
re2 = /^\s*B\n\s*M\s*.*\R/
p re1.match?("B\n  M;\n")  # prints true
p re2.match?("B\n  M;\n")  # also prints true
@jorendorff
Copy link
Author

Filed upstream: kkos/oniguruma#284

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

No branches or pull requests

2 participants