Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
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 Respuestas
Responde la pregunta

0

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

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

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 Denunciar

0

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

.* .* .* .*

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda