// 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)<div class="con news_content">(.*?)<\/div>"#).unwrap();
let string = "body = \"\"\"234234<div class=\"con news_content\">解决什么问题?解决人的æ€è€ƒï¼Ÿè¿˜æ˜¯è§£å†³äººçš„预测
还是解决现象?人工智能它的机ç†æ˜¯ä»€ä¹ˆï¼Œç®€å•æ¥è®²è‡³å°‘大数æ®å¯ä»¥åœ¨äººå·¥æ™ºèƒ½åšé¢„测决ç–的范畴起到促进作用。</p>
<p class=\"copyright\"</p>
</div></div>34234\"\"\"";
// result will be a tuple containing the start and end indices for the first match in the string
let result = regex.captures(string);
let (start, end) = match result {
Some((s, e)) => (s, e),
None => {
// ...
}
};
println!("{}", &string[start, end]);
}
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/