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

188
Visualizações
REGEX How can I check if a string has more than 2 spaces in it?

I am trying to regex (ECMAscript) check if a string has three or more spaces in it. Essentially, I want the minimum number of spaces to be 3 before it matches. Here are some examples;

"Microsoft and Apple" This would NOT match

"The quick brown fox" This WOULD match

"lots of spaces in this sentence" This WOULD match

This is the best I have so far;


/[\s]{3,}/gm


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

0

If the 'string' can contain everything (characters and numbers and special chars):

/^((.*?)? (.*?)?){3,}?$/gm
about 4 years ago · Juan Pablo Isaza Relatório

0

This may not be optimally efficient, but you could split on spaces and then check the resulting length:

const x = [
 "Microsoft and Apple",
 "The quick brown fox",
 "lots of spaces in this sentence",
]

x.forEach(s => console.log(s, s.split(' ').length > 3))

about 4 years ago · Juan Pablo Isaza Relatório

0

Put three spaces in the regex, and match anything else around them

.* .* .* .*

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