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.