Created
May 24, 2016 20:36
-
-
Save luzfcb/8d8fc0024de865c58075d18d7608e1ab to your computer and use it in GitHub Desktop.
django uuid slug regex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# match with uuid | |
# A UUID is a 16-octet (128-bit) number. | |
# | |
# In its canonical form, a UUID is represented by 32 lowercase hexadecimal digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and four hyphens). For example: | |
# | |
# 123e4567-e89b-12d3-a456-426655440000 | |
# The first 3 sequences are interpreted as complete hexadecimal numbers, while the final 2 as a plain sequence of bytes. The byte order is Big Endian (also known as network byte order)"'[1](sec. 4.1.2) (note that GUID's byte order is different). This form is defined in the RFC[1](sec. 3) and simply reflects UUID's division into fields,[1](sec. 4.1.2) which apparently originates from the structure of the initial time and MAC-based version. | |
# | |
# The number of possible UUIDs is 1632, which is 2128 or about 3.4 × 1038. | |
# https://en.wikipedia.org/wiki/Universally_unique_identifier#Definition | |
# https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29 | |
(?P<slug>\b[0-9A-Fa-f]{8}\b(-\b[0-9A-Fa-f]{4}\b){3}-\b[0-9A-Fa-f]{12}\b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment