Skip to content

Instantly share code, notes, and snippets.

@jakobii
Last active February 5, 2020 18:01
Show Gist options
  • Save jakobii/7f42e498703f96751390967835d2adda to your computer and use it in GitHub Desktop.
Save jakobii/7f42e498703f96751390967835d2adda to your computer and use it in GitHub Desktop.

uuid regex in golang

the straght forward answer

[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}

add case insensitivity

(?i:[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})

reduce repetition

(?i:[\dA-F]{8}-(?:[\dA-F]{4}-){3}[\dA-F]{12})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment