2 unstable releases
0.2.0 | Nov 23, 2022 |
---|---|
0.1.0 | Nov 8, 2022 |
#1684 in Text processing
35 downloads per month
16KB
355 lines
Route Pattern
A parser and matcher for a popular way to create route patterns.
Patterns like these that include regular expressions, delimited in this case by {
and }
:
/users/{[0-9]+}/update
Supports nested curlies here (inner curlies are serving the regular expression):
/users/{[0-9]{1,8}}/update
It lets you:
- Choose your delimiters:
{
,}
or<
,>
or others - Compile into a
Regex
or try a match
Dependency
[dependencies]
route-pattern = "0.1.0"
For most recent version see crates.io
Usage
let answer = route_pattern::is_match("foo/{b{1,4}}/{[0-9]+}", '{', '}', "foo/bbb/123")?
Or get a Regex
and use it later
let re = route_pattern::compile("foo/{b{1,4}}/{[0-9]+}", '{', '}')?;
Copyright
Copyright (c) 2022 @jondot. See LICENSE for further details.
Dependencies
~2.4–4.5MB
~79K SLoC