Marek Sebera Marek Sebera - 2 years ago 371
Javascript Question

How to test valid UUID/GUID?

How to check if variable contains valid UUID/GUID identifier ?

I'm currently interested only in validating types 1 and 4, but it's not limit for your answer.

Answer Source

Currently, UUID's are as specified in RFC4122.

Therefore to validate a UUID...


...ensures you have a canonically formatted UUID that is Version 1 through 5 and is the appropriate Variant as per RFC4122.

NOTE: Braces "{" and "}" are not canonical. They are an artefact of some systems and usages.

Easy to modify the above regex to meet the requirements of the original question.

HINT: regex group/captures

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download