11

Just when I generated a GUID, I found some hyphens in between the character and also at specified intervals

8b55fec7-c987-4e7b-abad-16e5aaea9b53

Is there any story behind this?

Note: My intention is to remove those hyphens as I am adding this GUID to a filename and our filename should only be aplhanumeric.

3
  • 1
    I think it's for readability. Although I must say it's a very strange placement of hyphens if that's the reason for them...
    – gablin
    Dec 25, 2010 at 22:54
  • A GUID has several fields
    – JoelFan
    Feb 26, 2015 at 22:15
  • See more stackoverflow.com/a/24484051 and stackoverflow.com/a/786541, which I found after asking myself a similarly worded question to the OP. Though apparently not technically valid per the spec without the hyphens, it appears to have no legitimate functional purpose for the UUID itself. See RFC4122 for lots of detail. Dec 21, 2020 at 14:12

2 Answers 2

16

The hyphens are always placed at the same position, so you won't lose any information (or unique-ness) by removing them.

See Stack Overflow: Why are there dashes in a .NET GUID? for a detailed explanation.

8

Long sequences are very hard to parse for humans, hence the hyphens. But GUID itself is just a number, so you can drop them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.