aboutsummaryrefslogtreecommitdiff
path: root/src/dl_list.rs
blob: 332738818399eb1d9b1ef979b32251d65784a670 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
use super::regex::Regex;

#[derive(Debug, Serialize)]
pub struct DLListItem {
    name: String,
    value: String,
}

pub fn parse(s: &str) -> Vec<DLListItem> {
    let reg_list_item = Regex::new(r#"(?is)<dt.*?>(.*?)</dt>.*?<dd>(.*?)</dd>"#).unwrap();

    reg_list_item.captures_iter(s).map(|c| DLListItem { name: c.at(1).unwrap().into(), value: c.at(2).unwrap().into() }).collect()
}