// 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"(?s)\<(ol)(?: .*?)?\>(?:[^\<]|\<(.*?)\>.*\<\/\2\>)*\<\/\1\>").unwrap();
let string = "<ol>kjkjkj
</ol>
<ol s>
<li>Table of Contents.....................CT.TS</li>
<li>Gamecube Controls.....................CN.GC</li>
<li>Nintendo 64 Controls..................CN.64</li>
<li>Walkthrough...........................01.00
<ol>
<li>Kokiri Forest...............01.01</li>
</ol>
</li>
<li>Sidequests & Minigames................02.00
<ol>
<li>Shooting Gallery............02.01</li>
</ol>
</li>
<li>Boss Guide............................03.00
<ol>
<li>Gohma.......................03.01</li>
<li>Final Boss [Second Form]....03.15</li>
</ol>
</li>
<li>Item Checklist........................04.00
<ol>
<li>Final Dungeon...............04.47</li>
</ol>
</li>
<li>Shop Inventory........................05.00
<ol>
<li>Kokiri Shop [Young].........05.01</li>
<li>Goron Shop [Adult]..........05.09</li>
</ol>
</li>
<li>Ocarina Notes.........................06.00
<ol><ol>sdsds</ol>
<li>Requ<ol></ol>iem of Spirit...........06.12</li>
</ol>
</li>
<li>Heart Containers......................07.00</li>
<li>Item List.............................15.00</li>
<li>Legal & Copyright.....................LE.AL</li>
<li>Credits & Thanks......................CR.DS</li>
</ol>
<ol><ol><ol><ol><ol></ol></ol></ol></ol></ol>
sdsd
k<ol>jlkjlkj
kjbkjh</ol> ";
// 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/