Crates.io | capturing-glob |
lib.rs | capturing-glob |
version | 0.1.1 |
source | src |
created_at | 2017-12-15 22:30:03.072755 |
updated_at | 2018-02-09 17:27:47.994604 |
description | An extension for unix shell style globs that allow to capture groups (i.e. remember matching character ranges) while matching. |
homepage | https://github.com/tailhook/capturing-glob |
repository | https://github.com/tailhook/capturing-glob |
max_upload_size | |
id | 43253 |
size | 97,842 |
Documentation | Github | Crate
Support for matching file paths against Unix shell style patterns, and capture groups when matching (similarly to captures in regexes).
And add this to your crate root:
extern crate capturing_glob;
Print all jpg files in /media/ and all of its subdirectories.
use capguring_glob::glob;
for entry in glob("/media/**/(*).jpg").expect("Failed to read glob pattern") {
match entry {
Ok(entry) => println!("Path {:?}, name {:?}",
entry.path().display(), entry.group(1).unwrap()),
Err(e) => println!("{:?}", e),
}
}
Note: in the case above, regular filename matching might be used
(i.e. file_stem()
), but the library allows you to skip unwraps here, but
more importantly you can use user-defined globs like these:
(*)/package.json
tests/(*).spec.js
docs/(section-*).rst
/usr/share/zoneinfo/(*/*)
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.