Coder Social home page Coder Social logo

Comments (4)

miss85246 avatar miss85246 commented on September 24, 2024 1

Got it, I will do that in this weekend.

from sanic-guide.

miss85246 avatar miss85246 commented on September 24, 2024

OK, but I have a question
which part is suitable? I think we can add it as an tip under the
routing -> Supported types -> regex

image

what do you think? @ahopkins @ZinkLu

from sanic-guide.

ZinkLu avatar ZinkLu commented on September 24, 2024

I tried group () and named group (?P<>), both works. so the idea is use regex group to get partial url? may be we should point that and have a python regex link below.

ie. https://docs.python.org/3/library/re.html?highlight=re%20compile#regular-expression-syntax

from sanic-guide.

ahopkins avatar ahopkins commented on September 24, 2024

That seems like a reasonable place to put it.

These should all be acceptable:

@app.get(r"/<foo:[a-z]{3}.txt>")
@app.get(r"/<foo:([a-z]{3}).txt>")
@app.get(r"/<foo:(?P<foo>[a-z]{3}).txt>")
@app.get(r"/<foo:(?P<foo>[a-z]{3}).(?:txt)>")
  1. matching on the full pattern
  2. defining a single matching group
  3. defining a single named matching group
  4. defining a single named matching group, with one or more non-matching groups

Also, if using a named matching group, it must be the same as the segment label.

from sanic-guide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.