Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

101
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda