Closed
Description
The simple regexes ((IMG|MVI|MGG)|DS)X
and (((IMG|MVI)|MG)|DS)X
both ought to match the string "MVIX
, but only the second one does.
extern crate regex;
use regex::{Regex};
fn main() {
simple_match_1();
simple_match_2();
}
/// This example working on regex101: https://regex101.com/r/WJgwJ5/1
#[test]
fn simple_match_1() {
let regex_str = "((IMG|MVI|MG)|DS)X";
let text = "MVIX";
let regex: Regex = Regex::new(regex_str).unwrap();
// These both panic when they shouldn't
assert!(regex.is_match(text));
assert!(regex.find(text) != None);
}
/// This example *does not* panic
#[test]
fn simple_match_2() {
let regex_str = "(((IMG|MVI)|MG)|DS)X";
let text = "MVIX";
let regex: Regex = Regex::new(regex_str).unwrap();
// These both *work* (no panic)
assert!(regex.is_match(text));
assert!(regex.find(text) != None);
}