// 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)(?:<td[^<]*>|\G(?!^))(?:<[^<]+>)?(?!\s+)([^<]*)(?:<[^<]+>)?").unwrap();
let string = "<table class=\"fiche_table_caracter\"><tbody>
<tr>
<td class=\"caracteristique\"><strong>Design</strong></td>
<td>Classique (full tactile)</td>
</tr>
<tr>
<td class=\"caracteristique\"><strong>Système d'exploitation (OS)</strong></td>
<td>iOS</td>
</tr>
<tr>
<td class=\"caracteristique\"><strong>Ecran</strong></td>
<td>4,7'' (1334 x 750 pixels)<br />16 millions de couleurs</td>
</tr>
<tr>
<td class=\"caracteristique\"><strong>Mémoire interne</strong></td>
<td>128 Go, 1 Go RAM</td>
</tr>
<tr>
<td class=\"caracteristique\"><strong>Appareil photo</strong></td>
<td>8 mégapixels</td>
</tr>
</tbody>
</table>";
// 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/