[Django]-Stop capturing any string based on / for urls in Django (regex)

8👍

Use [^/]+ instead of .+.

As Chris Pratt notes below, .+? will also work, as it is a “non-capturing” regex, which will match any character until a match for the following sub-expression. I generally prefer normal eager solutions to non-capturing solutions where possible, because they do not introduce multiple evaluation rules.

👤Marcin

Leave a comment