email-regex

v5.0.0
Regular expression for matching email addresses
email address regex regexp string match text test find and 3 more...

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 [email protected]');
//=> true

// Is an email address
emailRegex({exact: true}).test('[email protected]');
//=> true

'unicorn [email protected] cake [email protected] rainbow'.match(emailRegex());
//=> ['[email protected]', '[email protected]']

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.

npm i email-regex

Metadata

  • MIT
  • >=12
  • Sindre Sorhus
  • released 5/3/2021

Downloads

Maintainers