regexp for user_token

Hello

Just please confirm what is the correct reg exp (PHP) to verify user_token.
From what I saw the user_token looks like: "319925b0-7f56-403e-93ef-1ca3b4b32904".
So, I was thinking that ^[0-9a-z-]+$ should work, unless there are different formats depending on provider.

Pls.advise.

Bernard

Best Answer

  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    Answer ✓
    Hi Bernand,

    here what we use in one of our plugins:

    // Check if a given v4 UUID is valid public static function is_valid_v4 ($uuid) { return preg_match ('/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i', trim ($uuid)); }

    The format is always the same. The UUID is represented by 32 lowercase hexadecimal digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and four hyphens).

    Welcome!

    Please sign in to your OneAll account to ask a new question or to contribute to the discussions.

    Please click on the link below to connect to the forum with your OneAll account.