// 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#"(?m)<tr>\n\s*<td width="70"><strong>Released:<\/strong><\/td>\n\s*<td>(.*)<\/td>\n\s*<\/tr>\n\s*<tr>\n\s*<td width="70"><strong>Runtime:<\/strong><\/td>\n\s*<td>(.*)<\/td>\n\s*<\/tr>\n\s*<tr>\n\s*<td width="70"><strong>Genres:<\/strong><\/td>\n\s*<td><span class="movie_info_genres"><a\s[^<>]*>([^<>]*)<\/a>"#).unwrap();
let string = "<tr>
<td width=\"70\"><strong>Released:</strong></td>
<td>July 25, 2014</td>
</tr>
<tr>
<td width=\"70\"><strong>Runtime:</strong></td>
<td>90 mins </td>
</tr>
<tr>
<td width=\"70\"><strong>Genres:</strong></td>
<td><span class=\"movie_info_genres\"><a href=\"/?genre=Action\">Action</a> <a href=\"/?genre=Sci-Fi\">Sci-Fi</a> </span></td>
</tr>
<tr>
<td width=\"70\"><strong>Actors:</strong></td>
<td><span class=\"movie_info_actors\">
<a href=\"/?actor_name= Analeigh Tipton \"> Analeigh Tipton </a> <a href=\"/?actor_name= Morgan Freeman \"> Morgan Freeman </a> <a href=\"/?actor_name= Scarlett Johansson \"> Scarlett Johansson </a> <a href=\"/?actor_name=Min-sik Choi\">Min-sik Choi</a> </span></td>
</tr>";
// 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/