DeskKit

Regex library

Regular expression for usernames

A conservative username regex: starts with a letter, then 2–15 letters, digits, or underscores. Hyphens fail.

^[A-Za-z][A-Za-z0-9_]{2,15}$

Runs 100% in your browser. Nothing you paste is uploaded, stored, or sent to a server.

Flags

Highlighted matches

    How to use

    1. Scan the pre-filled pattern and the sample. Hits are highlighted; misses stay plain.
    2. Toggle flags if you need global or case-insensitive matching. The pattern is JavaScript / ECMAScript.
    3. Paste your own corpus. Nothing is sent to a server.
    4. Read the notes below before you drop the pattern into production — several of these are intentionally incomplete.

    Username rules are product policy, not a law of nature. This pattern is a conservative default: 3–16 characters, start with a letter, no hyphens or dots. It is easy to loosen and hard to tighten after you have users.

    It does not check reserved names (admin, root) or profanity. Those are list checks, not regex.

    What this pattern will not do

    Unicode letters are not allowed; add \p{L} with the u flag if you need them.

    Leading underscores fail because the first character class is letters only.

    FAQ

    Why start with a letter?

    So the name is a valid identifier in more languages and so “_system” can be reserved for the product.

    How do I allow hyphens?

    Add - to the second class: [A-Za-z0-9_-]. Keep it out of the first character.

    Is the sample text uploaded?

    No. The tester compiles the pattern with the browser’s RegExp engine and stays on the device.

    DeskKit is a static site. Interactive tools require JavaScript.