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

#[derive(Debug)]
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()
}