Skip to content

jamiekyle-eb/email-regex

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

email-regex Build Status

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

const emailRegex = require('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

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.

License

MIT © Sindre Sorhus

About

Regular expression for matching email addresses

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%