blob: db1b2eb29de15573c416d8c132ee4eb00326a0cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
use super::regex::Regex;
#[derive(Debug)]
pub struct Trait {
name: String,
value: String,
}
pub fn parse(s: &str) -> Vec<Trait> {
let reg_trait = Regex::new(r#"(?is)<dt.*?>(.*?)</dt>.*?<dd>(.*?)</dd>"#).unwrap();
reg_trait.captures_iter(s).map(|c| Trait { name: c.at(1).unwrap().into(), value: c.at(2).unwrap().into() }).collect()
}
|