Closed
Description
I believe I have found a bug in this library. I've tried to condense it down into the simplest possible test case which reproduces the problem:
#[test]
fn test_end_of_text() {
let re = regex!(r"a(b*(X|\z))?");
let text = "abcbX";
let ma = re.find(text).unwrap().as_str();
let mb = re.captures(text).unwrap().get(0).unwrap().as_str();
assert_eq!("a", ma);
assert_eq!(ma, mb);
}
I would expect this test case to pass. The first assert_eq!
does, but the second assert_eq!
reports that re.captures(
actually returned "ab" instead of just "a". It seems like (b*(X|\z))?
matches the b
following the a
and returns it as part of the full capture group, even though the following character c
doesn't match X|\z
. Interestingly, this only seems to happen when using captures
, and not find
.