email-regex
TypeScript icon, indicating that this package has built-in type declarations

5.0.0 • Public • Published

email-regex

Regular expression for matching email addresses

Use it for finding email addresses or checking if something is email like.

You shouldn't use this for validating emails. Only for hinting to the user.

Install

$ npm install email-regex

Usage

import emailRegex from 'email-regex';

// Contains an email address
emailRegex().test('unicorn sindresorhus@gmail.com');
//=> true

// Is an email address
emailRegex({exact: true}).test('sindresorhus@gmail.com');
//=> true

'unicorn sindresorhus@gmail.com cake john@doe.com rainbow'.match(emailRegex());
//=> ['sindresorhus@gmail.com', 'john@doe.com']

API

emailRegex(options?)

Returns a regex for matching email addresses.

options

Type: object

exact

Type: boolean
Default: false (Matches any email address in a string)

Only match an exact string.

Useful with RegExp#test to check if a string is an email address.

Package Sidebar

Install

npm i email-regex

Weekly Downloads

29,298

Version

5.0.0

License

MIT

Unpacked Size

4 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus