New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

regex-username

Package Overview
Dependencies
Maintainers
4
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regex-username

Regular expression for usernames - it follows the same rules that GitHub uses.

2.0.0
latest
Source
npm
Version published
Weekly downloads
4.5K
2.34%
Maintainers
4
Weekly downloads
 
Created
Source

regex-username

NPM version build status Test coverage Downloads

Regular expression for usernames - it follows the same rules that GitHub uses.

Installation

npm install regex-username

Usage

var regex = require('regex-username');

regex().test('foo-bar'); // => true
regex().test('foobar'); // => true
regex().test('3foobar'); // => true
regex().test('3foo-bar'); // => true
regex().test('foo-bar-'); // => false
regex().test('-foo-bar'); // => false
regex().test('foo--bar'); // => false
regex().test('~derp@darp---++asdf'); // => false
regex().test('derp@mail.com'); // => false

Why?

Which usernames to allow typically varies between applications. For prototypes however it's nice to have an off the shelf solution. This module is that solution. It follows the same rules GitHub uses:

Username may only contain alphanumeric characters or single hyphens, and cannot begin or end with a hyphen.

See Also

License

MIT

Keywords

regular expression

FAQs

Package last updated on 16 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts