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

210
Visualizações
How do I combine these three regex into one?

I'm trying to make a regular expression that only accepts:

Min 100 and atleast 1000 characters, characters “,’,<,> aren't allowed, two full stops one after another aren't allowed.

This is what I have for now:

  • ^.{100,1000}$ → for 100 to 1000 characters
  • ^[^"'<>]*$ → for the characters that aren't allowed
  • ^([^._]|[.](?=[^.]|$)|_(?=[^_]|$))*$ → doesn't allow 2 consecutive dots

How do I combine this regex into one? ._.

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

0

This part [^._] means no dot or underscore and this part [.](?=[^.]|$)|_(?=[^_]|$) matches either a . or _ followed by the opposite or end of string.

You could write the pattern using a single negative lookahead assertion excluding __ or ..

^(?!.*([._])\1)[^"'<>\n]{100,1000}$

Explanation

  • ^ Start of string
  • (?! Negative lookahead, assert that what is at the right is not
    • .*([._])\1 capture either . or _ and match the same captured char after it (meaning no occurrence of .. or __)
  • ) Close lookahead
  • [^"'<>\n]{100,1000} Match 100-1000 times any character except the listed
  • $ End of string

Regex demo (with the quantifier set to {10,100} for the demo)

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