Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 742 Bytes

README.md

File metadata and controls

25 lines (16 loc) · 742 Bytes

Minecraft UUID RegEx

RegEx for both dashless and dashed UUIDs provided by drainer / swede

/([0-9a-f]{8})(?:-|)([0-9a-f]{4})(?:-|)(4[0-9a-f]{3})(?:-|)([89ab][0-9a-f]{3})(?:-|)([0-9a-f]{12})/

if you are using this as a pattern remove the slashes

RegEx for UUID with dashes

/^[A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12}$/i

RegEx for UUID without dashes

/^[A-F\d]{8}[A-F\d]{4}4[A-F\d]{3}[89AB][A-F\d]{3}[A-F\d]{12}$/i

Usage

if (/([0-9a-f]{8})(?:-|)([0-9a-f]{4})(?:-|)(4[0-9a-f]{3})(?:-|)([89ab][0-9a-f]{3})(?:-|)([0-9a-f]{12})/.test('UUID_Here') === true) {
  console.log('This is a valid UUID.');
} else {
  console.log('This UUID is invalid.');
}