Created
July 20, 2023 02:51
-
-
Save aztack/518fce9989b9f7c9a7f7d63970d1464b to your computer and use it in GitHub Desktop.
Tell whether given string is a uuid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const uuidRegex = /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(--[0-9a-f]{5})?$/i; | |
function isUuid(str: string) { | |
if (typeof str !== 'string') return false; | |
return uuidRegex.test(str); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment