Skip to content

ajay-gandhi/email-address-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

email-address-util

Utilities for working with email addresses

Usage

# Install the package
npm install email-address-util
# Require it in your JS file
const EmailUtil = require("email-address-util");

Validate

Validate that the given string is a valid email address. This method uses the regular expression from W3, then validates the domain against IANA's list of valid TLDs.

EmailUtil.validate("valid@example.com")    # => true
EmailUtil.validate("in(valid@example.com") # => false

Extract

Extract the first email address found in the given string. Uses the same regular expression as validate.

const strWithEmail    = "My email address is jeff@jeff.com";
const strWithoutEmail = "My email address is above";
EmailUtil.extract(strWithEmail)   # => "jeff@jeff.com"
EmailUtil.extract(strWithoutEmai) # => false

Tests

Run tests with npm test.

About

Email validation and extraction tools

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published