From 37a539a2021d334c45e6fbfb9a34669af7cd69cf Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 12 Jul 2018 14:54:25 +0100 Subject: [PATCH] Add docs on regexs in routing --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 79feb932..02715ec5 100644 --- a/README.md +++ b/README.md @@ -297,6 +297,14 @@ Path('/users/{username}', app=User, methods=['GET']) Path components are made available in the scope, as `scope["kwargs"]`. +You can also use regular expressions for more complicated matching. + +Named capture groups will be included in `scope["kwargs"]`: + +```python +Path('/users/(?P[a-zA-Z0-9_]{1,20})', app=User, methods=['GET']) +``` + Because each target of the router is an ASGI instance itself, routers allow for easy composition. For example: