diff options
author | jan <jan@ruken.pw> | 2016-09-30 23:16:19 (UTC) |
---|---|---|
committer | jan <jan@ruken.pw> | 2016-09-30 23:16:19 (UTC) |
commit | a6b37fa5e1bd505adfae4888896be2a3aa49ec3a (patch) | |
tree | 0a381e0533489a78758b1516680e274f5fd82216 /src/traits.rs | |
parent | 361ea3a80a60bc6595a7a624b6cc5d71ddc8f6fc (diff) |
parsen von traits und tags, wir koennen den configkram eigentlich wieder komplett entfernen. klappt so nicht wirklich.
Diffstat (limited to 'src/traits.rs')
-rw-r--r-- | src/traits.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/traits.rs b/src/traits.rs new file mode 100644 index 0000000..db1b2eb --- /dev/null +++ b/src/traits.rs | |||
@@ -0,0 +1,13 @@ | |||
1 | use super::regex::Regex; | ||
2 | |||
3 | #[derive(Debug)] | ||
4 | pub struct Trait { | ||
5 | name: String, | ||
6 | value: String, | ||
7 | } | ||
8 | |||
9 | pub fn parse(s: &str) -> Vec<Trait> { | ||
10 | let reg_trait = Regex::new(r#"(?is)<dt.*?>(.*?)</dt>.*?<dd>(.*?)</dd>"#).unwrap(); | ||
11 | |||
12 | reg_trait.captures_iter(s).map(|c| Trait { name: c.at(1).unwrap().into(), value: c.at(2).unwrap().into() }).collect() | ||
13 | } | ||