且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP验证有效的UUID

更新时间:2023-09-24 13:02:16

根据 ***UUID v4 的格式为:

According to Wikipedia the format of UUID v4 is:

第 4 版 UUID 的格式为 xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx其中 x 是任何十六进制数字,y 是 8、9、A 或 B 之一.例如f47ac10b-58cc-4372-a567-0e02b2c3d479.

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. e.g. f47ac10b-58cc-4372-a567-0e02b2c3d479.

对应的正则表达式为:

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