// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r"_(.*?)(?=\\)").unwrap();
let string = "{\\\"header\\\":[[{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"text\\\",\\\"text\\\":\\\"<p>Opportunity<\\\\/p>\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"text\\\",\\\"text\\\":\\\"<p>Date<\\\\/p>\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"text\\\",\\\"text\\\":\\\"<p>Launch Vehicle<\\\\/p>\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"text\\\",\\\"text\\\":\\\"<p>Excess Capacity<\\\\/p>\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"text\\\",\\\"text\\\":\\\"<p>Orbit<\\\\/p>\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"text\\\",\\\"text\\\":\\\"<p>Cost<\\\\/p>\\\",\\\"type\\\":\\\"Paragraph\\\"}]}]],\\\"style\\\":\\\"normal\\\",\\\"body\\\":[[{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"reference\\\",\\\"sourceProperty\\\":\\\"name\\\",\\\"source\\\":\\\"_18_0_2_f280366_1447380313181_755886_144674\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"reference\\\",\\\"sourceProperty\\\":\\\"value\\\",\\\"source\\\":\\\"_18_0_2_f280366_1447380432770_58741_154478\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"reference\\\",\\\"sourceProperty\\\":\\\"value\\\",\\\"source\\\":\\\"_18_0_2_f280366_1447380396246_873072_144853\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"reference\\\",\\\"sourceProperty\\\":\\\"value\\\",\\\"source\\\":\\\"_18_0_2_f280366_1447380432768_736282_154472\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"reference\\\",\\\"sourceProperty\\\":\\\"value\\\",\\\"source\\\":\\\"_18_0_2_f280366_1447380395593_804641_144677\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"reference\\\",\\\"sourceProperty\\\":\\\"value\\\",\\\"source\\\":\\\"_18_0_2_f280366_1447380433550_448862_154654\\\",\\\"type\\\":\\\"Paragraph\\\"}]}]],\\\"title\\\":\\\"Possible Rideshares\\\",\\\"type\\\":\\\"Table\\\"}
IShouldGet3Match,allTheSequenceBetweenaUnderScoreAndASlashHere'sOne:_1234_1234\\andheresAnother_1234_1234_1234\\OhLookAnotherOne!_123_12_1234567\\bahbahba
";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Rust, please visit: https://docs.rs/regex/latest/regex/