Function Repository Resource:

UUIDQ

Source Notebook

Determine if an expression is a valid UUID

Contributed by: Richard Hennigan (Wolfram Research)

ResourceFunction["UUIDQ"][expr]

determines if expr is a valid UUID.

Details and Options

A UUID is a string based on a 128-bit number, formatted as 32 hexadecimal digits grouped in the format 8-4-4-4-12.

Examples

Basic Examples (4) 

Check the validity of a UUID:

In[1]:=
ResourceFunction["UUIDQ"]["46d3d75e-26d7-45e4-bb1c-6a0db275723a"]
Out[1]=
In[2]:=
ResourceFunction["UUIDQ"]["hello-world"]
Out[2]=

Uppercase is allowed:

In[3]:=
ResourceFunction["UUIDQ"]["348603D4-5862-4437-AD2B-EBCD132360F7"]
Out[3]=

Letters must be in the range a to f:

In[4]:=
ResourceFunction["UUIDQ"]["ga3d99e8-9932-4734-b006-b6fdfa96abb9"]
Out[4]=

Expressions that are not strings will return False:

In[5]:=
ResourceFunction["UUIDQ"][a + b]
Out[5]=

Possible Issues (2) 

Adding extra characters to a UUID will cause UUIDQ to return False:

In[6]:=
CreateUUID["prefix-"]
Out[6]=
In[7]:=
ResourceFunction["UUIDQ"][%]
Out[7]=

Separators must be hyphens:

In[8]:=
StringReplace[CreateUUID[], "-" -> "."]
Out[8]=
In[9]:=
ResourceFunction["UUIDQ"][%]
Out[9]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 2.0.0 – 22 November 2019
  • 1.0.0 – 09 November 2018

Related Resources

License Information