Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Regular Expressions/Email Address Validation/isEmail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;

const email = "example@email.com";

if (emailRegex.test(email)) {
console.log("Valid email address");
} else {
console.log("Invalid email address");
}
11 changes: 11 additions & 0 deletions Regular Expressions/Email Address Validation/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Email Address Validation

This regular expression checks if the provided string matches the common pattern for email addresses.

**Please note that the code is based on ES2021, and as such, will not work in the global scope or scopes that are not ES2021 compatible.**

^[a-zA-Z0-9._%+-]+: Matches one or more characters that can be letters (both uppercase and lowercase), digits, dots, underscores, percent signs, or plus or hyphen signs at the start of the string.
@: Matches the "@" symbol.
[a-zA-Z0-9.-]+: Matches one or more characters that can be letters, digits, dots, or hyphens in the domain part of the email address.
\.: Matches a dot.
[a-zA-Z]{2,}$: Matches two or more letters at the end of the string, representing the top-level domain (TLD) of the email address.