Rafael Rafael - 1 year ago 164
PHP Question

How to determine if a string is a valid v4 UUID?

I'm making a validator based on UUID generated by client browser, i use this to identify a certain type data that the user sends; and would like to validate that the

that client sends it is in fact a valid Version 4

I found this PHP preg_match UUID v4, it's close but not exactly what i'm looking for. i wish to know if exists something similar to
Where if string is not valid Sends

i could do based on the regular expression but i would like something more native to test it.

Any ideas?

Answer Source

Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B.


To allow lowercase letters, use i modifier.

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