# github-username-regex

> A regular expression that only matches a valid Github username

Latest version **1.0.0** (published 2017-01-18) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install github-username-regex
pnpm add github-username-regex
yarn add github-username-regex
bun add github-username-regex
```

## Health

**Score 28/100 (F)** — status: abandoned.

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-01-18 |
| First published | 2017-01-17 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | separate (@types/github-username-regex) |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 79 |
| Author | Shinnosuke Watanabe |
| Maintainers | shinnn |
| Keywords | github, name, username, login, account, validate, validation, match, regex, regexp |

## Links

- npm: https://www.npmjs.com/package/github-username-regex
- Repository: https://github.com/shinnn/github-username-regex
- Homepage: https://github.com/shinnn/github-username-regex#readme
- Issues: https://github.com/shinnn/github-username-regex/issues
- npm.io page: https://npm.io/package/github-username-regex

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-01-18
- 0.0.0 — 2017-01-17

## README

# github-username-regex

[![NPM version](https://img.shields.io/npm/v/github-username-regex.svg)](https://www.npmjs.com/package/github-username-regex)
[![Bower version](https://img.shields.io/bower/v/github-username-regex.svg)](https://github.com/shinnn/github-username-regex/releases)
[![Build Status](https://travis-ci.org/shinnn/github-username-regex.svg?branch=master)](https://travis-ci.org/shinnn/github-username-regex)

A regular expression that only matches a valid [Github](https://github.com/) username

```javascript
import githubUsernameRegex from 'github-username-regex';

githubUsernameRegex.test('john'); //=> true
githubUsernameRegex.test('john-due'); //=> true
githubUsernameRegex.test('john-due-'); //=> false
```

According to the form validation messages on [*Join Github*](https://github.com/join) page,

* Github username may only contain alphanumeric characters or hyphens.
* Github username cannot have multiple consecutive hyphens.
* Github username cannot begin or end with a hyphen.
* Maximum is 39 characters.

## Installation

### [npm](https://www.npmjs.com/)

```
npm install github-username-regex
```

### [bower](https://bower.io/)

```
bower install github-username-regex
```

## API

```javascript
import githubUsernameRegex from 'github-username-regex';
```

### githubUsernameRegex

Type: [`RegExp`](https://developer.mozilla.org/docs/Web/JavaScript/Guide/Regular_Expressions) (`/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i`)

```javascript
// Returns `true`
githubUsernameRegex.test('a');
githubUsernameRegex.test('0');
githubUsernameRegex.test('a-b');
githubUsernameRegex.test('a-b-123');
githubUsernameRegex.test('a'.repeat(39));

// Returns `false`
githubUsernameRegex.test('');
githubUsernameRegex.test('a_b');
githubUsernameRegex.test('a--b');
githubUsernameRegex.test('a-b-');
githubUsernameRegex.test('-a-b');
githubUsernameRegex.test('a'.repeat(40));
```

Note 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.

## License

[Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/deed)

---
_Source: https://npm.io/package/github-username-regex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
