Is there any difference to use [0-9]+ vs d+ in django url patterns?
Any security difference?
-
3Possible duplicate of Does "\d" in regex mean a digit?itzMEonTV– itzMEonTV2017-12-21 12:30:18 +00:00Commented Dec 21, 2017 at 12:30
-
This StackOverflow question may be helpful for more information on django url patternsJosh Withee– Josh Withee2017-12-21 12:31:54 +00:00Commented Dec 21, 2017 at 12:31
Add a comment
|
1 Answer
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]
1 Comment
zipa
Was about to write the same +1