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

106
Vistas
Regular expression to not accept . at the end of the email address in React

I want to construct a regular expression where . is not allowed as the last and first character of the email address (example: .abc.@gmail.com should not be accepted). Also, I have another requirement that .. 2 consecutives periods should not be allowed anywhere in the email address (example: abc...def@gmail.com).

The regular expression that I am currently using is : let regEx = new RegExp(/^[a-zA-Z0-9+_.-]+@(\[(\d{1,3}\.)(([a-zA-Z\d-]+\.)+))([a-zA-Z]{2,15}|\d{1,3})(\]?)/);.

Can I get some help in modifying the above regular expression to fulfill my requirement?

PS: I have very little knowledge on regular expressions.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Adding your 2 new requirements we can try:

^(?!.*\.\.)[\p{L}\p{N}\s,_-][\p{L}\p{N}\s,._-]*[\p{L}\p{N}\s,_-]$

Explanation:

^                        from the start of the email
    (?!.*\.\.)           no two or more consecutive dots
    [\p{L}\p{N}\s,_-]    first character is not dot
    [\p{L}\p{N}\s,._-]*  zero or more allowed characters, including dot
    [\p{L}\p{N}\s,_-]    last character is not dot
$                        end of the email
about 4 years ago · Juan Pablo Isaza 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