{"id":13615610,"url":"https://github.com/shinnn/github-username-regex","last_synced_at":"2026-03-15T04:42:08.320Z","repository":{"id":57251291,"uuid":"79323701","full_name":"shinnn/github-username-regex","owner":"shinnn","description":"A regular expression that only matches a currently valid Github username","archived":false,"fork":false,"pushed_at":"2023-01-02T16:02:47.000Z","size":2,"stargazers_count":77,"open_issues_count":3,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-18T19:59:31.309Z","etag":null,"topics":["account","javascript","regular-expression","username","validation"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shinnn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-18T09:21:43.000Z","updated_at":"2024-10-17T03:55:41.000Z","dependencies_parsed_at":"2023-02-01T03:31:06.575Z","dependency_job_id":null,"html_url":"https://github.com/shinnn/github-username-regex","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fgithub-username-regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fgithub-username-regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fgithub-username-regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fgithub-username-regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinnn","download_url":"https://codeload.github.com/shinnn/github-username-regex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232333558,"owners_count":18507054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["account","javascript","regular-expression","username","validation"],"created_at":"2024-08-01T20:01:15.716Z","updated_at":"2026-03-15T04:42:03.283Z","avatar_url":"https://github.com/shinnn.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# github-username-regex\n\n[![NPM version](https://img.shields.io/npm/v/github-username-regex.svg)](https://www.npmjs.com/package/github-username-regex)\n[![Bower version](https://img.shields.io/bower/v/github-username-regex.svg)](https://github.com/shinnn/github-username-regex/releases)\n[![Build Status](https://travis-ci.org/shinnn/github-username-regex.svg?branch=master)](https://travis-ci.org/shinnn/github-username-regex)\n\nA regular expression that only matches a valid [Github](https://github.com/) username\n\n```javascript\nimport githubUsernameRegex from 'github-username-regex';\n\ngithubUsernameRegex.test('john'); //=\u003e true\ngithubUsernameRegex.test('john-due'); //=\u003e true\ngithubUsernameRegex.test('john-due-'); //=\u003e false\n```\n\nAccording to the form validation messages on [*Join Github*](https://github.com/join) page,\n\n* Github username may only contain alphanumeric characters or hyphens.\n* Github username cannot have multiple consecutive hyphens.\n* Github username cannot begin or end with a hyphen.\n* Maximum is 39 characters.\n\n## Installation\n\n### [npm](https://www.npmjs.com/)\n\n```\nnpm install github-username-regex\n```\n\n### [bower](https://bower.io/)\n\n```\nbower install github-username-regex\n```\n\n## API\n\n```javascript\nimport githubUsernameRegex from 'github-username-regex';\n```\n\n### githubUsernameRegex\n\nType: [`RegExp`](https://developer.mozilla.org/docs/Web/JavaScript/Guide/Regular_Expressions) (`/^[a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38}$/i`)\n\n```javascript\n// Returns `true`\ngithubUsernameRegex.test('a');\ngithubUsernameRegex.test('0');\ngithubUsernameRegex.test('a-b');\ngithubUsernameRegex.test('a-b-123');\ngithubUsernameRegex.test('a'.repeat(39));\n\n// Returns `false`\ngithubUsernameRegex.test('');\ngithubUsernameRegex.test('a_b');\ngithubUsernameRegex.test('a--b');\ngithubUsernameRegex.test('a-b-');\ngithubUsernameRegex.test('-a-b');\ngithubUsernameRegex.test('a'.repeat(40));\n```\n\nNote that this module doesn't take reserved usernames into consideration. For example it matches `help`, `about` and `pricing`, though they are reserved words and cannot be used as Github usernames.\n\n## License\n\n[Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/deed)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Fgithub-username-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinnn%2Fgithub-username-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Fgithub-username-regex/lists"}