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

182
Visualizações
regex js how to to exclude from a match two consecutive zeros?

I have the following regular expression

^[2-9][0-9]{3}-W([0-5][0-3]|(?!00))

https://regex101.com/r/OOCxzT/1

I need to exclude from the match a string with two consecutive 00 for instance

2022-W00

I added (?!00) but does not seem to work properly.

Any idea how to fix it?

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

0

Using the negative lookahead in the alternation ([0-5][0-3]|(?!00)) this part (?!00) will be true (giving you a partial match) if the first alternative does not match, and from the current position what is directly to the right is not 00

The lookahead should be right before the second match of the digits.

^[2-9][0-9]{3}-W(?!00)([0-5][0-3])

Regex demo

If you only want to match 2 digits, you can also append an anchor $

^[2-9][0-9]{3}-W(?!00)([0-5][0-3])$
about 4 years ago · Juan Pablo Isaza Relatório

0

Is this what you need ? or more digit after 'W' ?

^[2-9][0-9]{3}-W([0-5][1-3]|[1-5][0-3])
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