Q:

What set of chars is php's uniqid composed of?

I would like to prepare simple regular expression for php's uniqid. I checked  uniqid manual looking for set of chars used as return value. But the documentation only mention that:

@return string the unique identifier, as a string.

And

With an empty prefix, the returned string will be 13 characters long. If more_entropy is true, it will be 23 characters.

I would like to know what characters can I expect in the return value. Is it a hex string? How to know for sure? Where to find something more about the uniqid function?

A:

The documentation doesn't specify the string contents; only its length. Generally, you shouldn't depend on it.  If you print the value between a pair of delimiters, like quotation marks, you could use them in the regular expression:
"([^"]+)"    ($1 contains the value)

As long as you develop for a particular PHP version, you can inspect its implementation and assume, that it doesn't change.  If you upgrade, you should check, if the assumption is still valid.
A comment in uniqid documentation describes, that it is essentially a hexadecimal number with an optional numeric suffix:
if (more_entropy) {
    uniqid = strpprintf(0, "%s%08x%05x%.8F", prefix, sec, usec, php_combined_lcg() * 10);
} else {
    uniqid = strpprintf(0, "%s%08x%05x", prefix, sec, usec);
}

Which gives you two possible output formats:

uniqid() - 13 characters, hexadecimal number
uniqid('', true) - 14 - 23 characters, hexadecimal number with floating number suffix
computed elsewhere

If you use other delimiters than alphanumeric characters and dot, you could use one of these simple regular expressions to grab the value in either of the two formats:

[0-9a-f]+
[.0-9a-f]+

If you need 100% format guarantee for any PHP version, you could write your own function based on sprintf.
I admit, that it is unlikely, that the uniqid would significantly change; I would expect creating other extensions to provide different formats.  Another comment in uniqid documentation shows a RFC 4211 compliant UUID implementation.  There was also a discussion on stackoverflow about it.

