0

Is there any difference to use [0-9]+ vs d+ in django url patterns? Any security difference?

2

1 Answer 1

3

Django uses pythons re module, and from its documentation:

\d [...] Matches any Unicode decimal digit (that is, any character in Unicode character category [Nd]). This includes [0-9], and also many other digit characters. If the ASCII flag is used only [0-9] is matched (but the flag affects the entire regular expression, so in such cases using an explicit [0-9] may be a better choice).

That is, this would also match e.g. arabic numbers. If you want that, then use \d, if not, then use [0-9]

Sign up to request clarification or add additional context in comments.

1 Comment

Was about to write the same +1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.