#glob #regex #parser #text-file #text-parser #text

parseit

Simple text file parsing library powered by regex and glob patterns

3 releases

0.1.2 Jan 15, 2023
0.1.1 Aug 30, 2022
0.1.0 Apr 9, 2022

#39 in #glob

Download history 22/week @ 2024-07-22 33/week @ 2024-07-29 32/week @ 2024-08-05 24/week @ 2024-08-12 23/week @ 2024-08-19 40/week @ 2024-08-26 23/week @ 2024-09-02 18/week @ 2024-09-09 25/week @ 2024-09-16 54/week @ 2024-09-23 30/week @ 2024-09-30 31/week @ 2024-10-07 43/week @ 2024-10-14 22/week @ 2024-10-21 39/week @ 2024-10-28 28/week @ 2024-11-04

141 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

16KB
304 lines

parseit

GitHub Workflow Status Crates.io docs.rs Codecov

Simple text file parsing library powered by regex and glob patterns.

// Create a parser to parse sections in Cargo.toml (and optionally Cargo.lock)
let parser = Parser::new(&["Cargo.*"], &["Cargo.toml"], r#"^\[(.*)\]$\n"#).unwrap();

// Parse the files in the manifest directory.
let documents = parser
    .parse(&PathBuf::from(env!("CARGO_MANIFEST_DIR")))
    .unwrap();

// Print results.
for document in documents {
    println!("Path: {}", document.path.to_string_lossy());
    for paragraph in document.paragraphs {
        println!("Title: {}", paragraph.title);
        println!("Contents: {}", paragraph.contents);
        println!();
    }
}

Examples

See examples.

Cargo Features

  • gzip: support reading gzip (.gz) files

License

Licensed under either of Apache License Version 2.0 or The MIT License at your option.

Contribution

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.

Copyright © 2022-2023, Orhun Parmaksız

Dependencies

~4–13MB
~147K SLoC