Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Python

r"
[0-9a-f]{32}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
"
gm

Description

Python regex used to parse a UUID in its full form (36 chars, including hyphens in 12-4-4-4-12 form), and its compact 32 char form (derived from uuid.hex).

This regex was originally created for a Django url converter that supported uuids in both forms.

Submitted by anonymous - 5 years ago