Skip to content

๐Ÿ˜Ž Allows you to write human-readable regular expressions in Rust programming language.

License

Notifications You must be signed in to change notification settings

abs0luty/pretty_regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

27 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”ฎ Write readable regular expressions

The crate provides a clean and readable way of writing your regex in the Rust programming language:

Without pretty_regex

With pretty_regex

\d{5}(-\d{4})?
digit() * 5 + (just("-") + digit() * 4).optional()
^(?:\d){4}(?:(?:\-)(?:\d){2}){2}$
beginning() + digit() * 4
            + (just("-") + digit() * 2) * 2
            + ending()
rege(x(es)?|xps?)
just("rege") + (just("x") + just("es").optional())
             | (just("xp") + just("s").optional())

How to use the crate?

To convert a PrettyRegex into a regex from regex crate, you can call to_regex or to_regex_or_panic:

use pretty_regex::digit;

let regex = (digit() + ascii_alphabetic().optional()).to_regex_or_panic();

assert!(regex.is_match("3"));

About

๐Ÿ˜Ž Allows you to write human-readable regular expressions in Rust programming language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages