This content originally appeared on Bram.us and was authored by Bramus!
grex
is a library as well as a command-line utility that is meant to simplify the often complicated and tedious task of creating regular expressions. It does so by automatically generating a single regular expression from user-provided test cases. The resulting expression is guaranteed to match the test cases which it was generated from.
As Stefan shows: simply type in some terms into grex
that you want to match and the RegExp comes out … ?
I just learned about the CLI tool `grex`. It might change how I approach regular expressions (??).
You provide string values and it comes up with a regular expression matching them.?https://t.co/69y4NGcwjQ
Video alt: CLI session showing multiple generated reg. expressions. pic.twitter.com/20A9W4C6Zr
— Stefan Judis (@stefanjudis) March 21, 2021
Also available as a Rust library.
use grex::RegExpBuilder;
let regexp = RegExpBuilder::from(&["a", "aa", "aaa"]).build();
assert_eq!(regexp, "^a(?:aa?)?$");
This content originally appeared on Bram.us and was authored by Bramus!
Bramus! | Sciencx (2021-03-26T20:48:14+00:00) Automatically Generate Regular Expressions from User Input with grex. Retrieved from https://www.scien.cx/2021/03/26/automatically-generate-regular-expressions-from-user-input-with-grex/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.