Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orhun/parseit
A simple text file parsing library powered by regex and glob patterns
https://github.com/orhun/parseit
glob-pattern parser-library parsing regex rust text-file-parser text-parser
Last synced: 29 days ago
JSON representation
A simple text file parsing library powered by regex and glob patterns
- Host: GitHub
- URL: https://github.com/orhun/parseit
- Owner: orhun
- License: apache-2.0
- Created: 2022-04-09T13:34:33.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-19T08:52:51.000Z (12 months ago)
- Last Synced: 2024-05-09T20:57:04.380Z (6 months ago)
- Topics: glob-pattern, parser-library, parsing, regex, rust, text-file-parser, text-parser
- Language: Rust
- Homepage:
- Size: 51.8 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# parseit
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/orhun/parseit/ci.yml)](https://github.com/orhun/parseit/actions)
[![Crates.io](https://img.shields.io/crates/v/parseit)](https://crates.io/crates/parseit)
[![docs.rs](https://img.shields.io/docsrs/parseit)](https://docs.rs/parseit/latest)
[![Codecov](https://img.shields.io/codecov/c/gh/orhun/parseit)](https://app.codecov.io/gh/orhun/parseit)Simple text file parsing library powered by [regex](https://en.wikipedia.org/wiki/Regular_expression) and [glob patterns]().
```rs
// 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](./examples/).
## Cargo Features
- `gzip`: support reading gzip (`.gz`) files
## License
Licensed under either of [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) or [The MIT License](http://opensource.org/licenses/MIT) 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
Copyright © 2022-2024, [Orhun Parmaksız](mailto:[email protected])