Skip to content

Real Regex for the regex option #11

@yovanoc

Description

@yovanoc
const emailReg = new RegExp(
  /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
);
/**
 * Validate email function with regular expression
 *
 * If email isn't valid then return false
 *
 * @param email
 * @return Boolean
 */
export const validateEmail = (email: string): boolean => emailReg.test(email);

I use this function in several projects. I think it's more robust than the regex option here, but I need all your other options, so what do you think?

thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions