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

236
Visualizações
Regex for email (shouldn't match string after ; )

I have the following regex: /(\s?[^\s,]+@[^\s,]+.[^\s,]+\s?;)*(\s?[^\s,]+@[^\s,]+.[^\s,]+)/g

Could you tell me why it matches this string: "hNw6B@90.com;tesr" and doesn't match this one: "hNw6B@90.com; test" ?

It shouldn't match the first string. However if there is a valid email after the ; like test@abv.bg, it should be matched.

I will be very grateful if you could help me out.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use

^[^@\s;]+@[^\s;]+\.[^\s;]+(?:\s*;\s*[^@\s;]+@[^\s;]+\.[^\s;]+)*;?$

See the regex demo. Details:

  • ^ - start of string
  • [^@\s;]+ - zero or more chars other than @, whitespace and ;
  • @ - a @ char
  • [^\s;]+ - zero or more chars other than whitespace and ;
  • \. - a dot
  • [^\s;]+ - zero or more chars other than whitespace and ;
  • (?:\s*;\s*[^@\s;]+@[^\s;]+\.[^\s;]+)* - zero or more repetition of a ; enclosed with zero or more whitespaces, and then the same pattern as above
  • ;? - an optional ;
  • $ - end of string.
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