regex_generate

Use regular expressions to generate text. This crate is very new and raw. It's a work-in-progress, but feel free to add issues or PRs or use it for your own ideas, if you find it interesting. No guarantees or warranties are implied, use this code at your own risk.

Thanks to the amazing folks who work on rust-lang/regex which is the heart of this crate. Using regex_syntax made this crate 1000x easier to produce.

Documentation

None yet, coming soon.

Usage

Add this to your Cargo.toml:

toml [dependencies] regex_generate = "0.1"

and this to your crate root:

rust extern crate regex_generate;

This example generates a date in YYYY-MM-DD format and prints it.

```rust extern crate regex_generate;

use regex_generate::{Generate, Generator};

fn main() { let gen = Generator::new(r"(?x) (?P[0-9]{4}) # the year - (?P[0-9]{2}) # the month - (?P[0-9]{2}) # the day ").unwrap(); let mut buffer = vec![]; gen.generate(&mut buffer).unwrap(); let output = String::from_utf8(buffer).unwrap();

println!("Random Date: {}", output);

}!("Random Date: {}", output); ```

Tests

Run tests with cargo test

Benches

Run benchmarks with rustup run nightly cargo bench

Tips

TODO

License

regex_generate is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, and LICENSE-MIT for details.