Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

83
Vistas
Regex for Email ([A-Za-z]{2,4})$/

I was reading this link to understand regex: https://www3.ntu.edu.sg/home/ehchua/programming/howto/Regexe.html

In my code, Here is what I have:

var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

I was testing this email: "test@tatsu.works", and I got error "Please Enter Valid Email ID"

If I understand correct, it is related to the ending section .([A-Za-z]{2,4})$/

I though the {2,4} means 2 to 4 characters, so I changed to {2,6}, but still getting error. Basically the ".works" can be any number of characters.

Can I know what I do wrong?

Kind Regards

================================================================= EDIT: Apparently, changing to {2,6} or {2,} works, but the reason why it is not working for me is because I am using Chrome and somehow the javascipt is not refreshed (I think related to cookie)

When I switched to Edge, the regex works.

Anyway Thanks to user Wiktor Stribiżew

almost 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Parsing emails for validity using a regex is a non trivial problem.

These are all valid emails that your regex will fail

'Long live the king'@com
This\ is\ my#@email.address
Fred\@barney@bedrock.gov

See https://beesbuzz.biz/code/439-Falsehoods-programmers-believe-about-email and look up the bits about email addresses.

almost 4 years ago · Santiago Trujillo Denunciar

0

I'd just use filter_var with the FILTER_VALIDATE_EMAIL flag to check, if an email address is in the correct format.

if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
  // valid email address
}
almost 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda