Marek Sebera Marek Sebera - 5 months ago 59x
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.


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