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.
npm install email-regex
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]']
Returns a regex for matching email addresses.
Type: object
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.
If you run the regex against untrusted user input in a server context, you should give it a timeout. It's also a good idea to limit the input to a reasonable length.
I do not consider ReDoS a valid vulnerability for this package.