blob: 63db847e642dddbf531a0039d4637dc10eaa49b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
use super::regex::Regex;
use std::str::FromStr;
#[derive(Debug, Serialize)]
pub struct Tag {
pub id: u32,
pub name: String,
}
pub fn parse(s: &str) -> Vec<Tag> {
let reg_tag = Regex::new(r#"(?is)<a href="tags\.php\?id=([0-9]+)">(.*?)</a>"#).unwrap();
reg_tag.captures_iter(s)
.map(|c| {
Tag {
id: u32::from_str(c.at(1).unwrap()).unwrap(),
name: c.at(2).unwrap().into(),
}
})
.collect()
}
|