| Crates.io | regex-map |
| lib.rs | regex-map |
| version | 0.1.0 |
| created_at | 2023-10-04 09:12:27.841114+00 |
| updated_at | 2023-10-04 09:12:27.841114+00 |
| description | Associative container where the keys are regular expressions. |
| homepage | https://github.com/Palmik/regex-map-rs |
| repository | https://github.com/Palmik/regex-map-rs |
| max_upload_size | |
| id | 992008 |
| size | 7,435 |
Associative container where the keys are regular expressions, based on the regex::RegexSet data structure.
use regex_map::RegexMap;
let map = RegexMap::new([
("foo", 1),
("bar", 2),
("foobar", 3),
("^foo$", 4),
("^bar$", 5),
("^foobar$", 6),
]);
assert_eq!(map.get("foo").cloned().collect::<Vec<_>>(), vec![1, 4]);
assert_eq!(map.get("bar").cloned().collect::<Vec<_>>(), vec![2, 5], );
assert_eq!(map.get("foobar").cloned().collect::<Vec<_>>(), vec![1, 2, 3, 6]);
assert_eq!(map.get("XXX foo XXX").cloned().collect::<Vec<_>>(), vec![1]);
assert_eq!(map.get("XXX bar XXX").cloned().collect::<Vec<_>>(), vec![2]);
for value in map.get("foo") {
println!("Foo match: {}", value);
}
get_with_match, which would return iterator over the values and the matches for the individual regexes.