javascript regex email

To validate an email address using JavaScript regex, you can use the following pattern:

const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

This regex pattern checks if the email address has the correct format, including an "@" symbol and a valid domain name. Here's an example of how you can use it:

const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
const email = "[email protected]";

if (emailPattern.test(email)) {
    console.log("Valid email address");
} else {
    console.log("Invalid email address");
}

In this example, the test() method checks if the email matches the regex pattern. If it does, it will log "Valid email address"; otherwise, it will log "Invalid email address".