You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#![feature(phase)]
#[phase(plugin)]
extern crate regex_macros;
extern crate regex;
fn main() {
let re = regex!(r#"([AB])"#);
println!("\n1 {}", re);
for cap in re.captures_iter("AABBAB") {
println!("0: {}, 1: {}", cap.at(0), cap.at(1));
}
let re = regex!(r#"([\x{5b}])"#);
println!("\n2 {}", re);
for cap in re.captures_iter("[[]][]") {
println!("0: {}, 1: {}", cap.at(0), cap.at(1));
}
let re = regex!(r#"([\[])"#);
println!("\n3 {}", re);
for cap in re.captures_iter("[[]][]") {
println!("0: {}, 1: {}", cap.at(0), cap.at(1));
}
let re = regex!(r#"([\x{5d}])"#);
println!("\n4 {}", re);
for cap in re.captures_iter("[[]][]") {
println!("0: {}, 1: {}", cap.at(0), cap.at(1));
}
let re = regex!(r#"([\]])"#);
println!("\n5 {}", re);
for cap in re.captures_iter("[[]][]") {
println!("0: {}, 1: {}", cap.at(0), cap.at(1));
}
let re = regex!(r#"([\x{5b}\x{5d}])"#);
println!("\n6 {}", re);
for cap in re.captures_iter("[[]][]") {
println!("0: {}, 1: {}", cap.at(0), cap.at(1));
}
let re = regex!(r#"([\x{5d}\x{5b}])"#);
println!("\n7 {}", re);
for cap in re.captures_iter("[[]][]") {
println!("0: {}, 1: {}", cap.at(0), cap.at(1));
}
let re = regex!(r#"([\[\]])"#);
println!("\n8 {}", re);
for cap in re.captures_iter("[[]][]") {
println!("0: {}, 1: {}", cap.at(0), cap.at(1));
}
let re = regex!(r#"([\]\[])"#);
println!("\n9 {}", re);
for cap in re.captures_iter("[[]][]") {
println!("0: {}, 1: {}", cap.at(0), cap.at(1));
}
let re = regex!(r#"\[|\]"#);
println!("\n10 {}", re);
for cap in re.captures_iter("[[]][]") {
println!("0: {}, 1: {}", cap.at(0), cap.at(1));
}
}
I expect case 6, 7, 8, and 9 to behave like 1 and 10. It looks like something about having both a left and right quoted bracket within a character set is causing the regex engine to treat the character set as
a literal "[]" that matches a single time (even though that sequence appears twice in the text).
The same behavior happens with Regex::new instead of regex! macro.
The text was updated successfully, but these errors were encountered:
Here is my test code:
Results:
I expect case 6, 7, 8, and 9 to behave like 1 and 10. It looks like something about having both a left and right quoted bracket within a character set is causing the regex engine to treat the character set as
a literal "[]" that matches a single time (even though that sequence appears twice in the text).
The same behavior happens with Regex::new instead of regex! macro.
The text was updated successfully, but these errors were encountered: