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

177
Vistas
Regex having "." (no other special characters) between text it can have many dots with text around but not two dots consecutively "example.one.three"

so I am looking for a regex which disallows two consecutive "." but it can have many. Also the string should not start or end with ".".

I've written a regex but it allows multiple dots consecutively.

new RegExp("^[0-9a-z].*[0-9a-z]$", "i"),

valid examples

"abc.def.hun.asasdsd"
"asasaasass.l"
"p.asasasas"

invalid examples

".asassa"
"sasas..sasas.sas"
"asas.sasas.sasas."
"sasas...sasasdsd.sasass"
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You may use this regex:

/^[a-z\d](?!.*\.\.)(?:.*[a-z\d])?$/gmi

RegEx Demo

Explanation:

  • ^[a-z\d]: Match alphanumeric char at start
  • (?!.*\.\.): Negative lookahead to fail the match if 2 consecutive dots are present anywhere
  • (?:.*[a-z\d])?: Match anything followed by alphanumeric char. Make this an optional group match
  • $: End
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use this command, to start with ^[0-9a-z] with the number of letters, and then groups of dot with letters and numbers but not two sequential dots.

const result = new RegExp("^[0-9a-z]+?(\.[0-9a-z]+)*$", "i").test('one.dsfsdf.');

console.log(result)

about 4 years ago · Juan Pablo Isaza Denunciar

0

Perhaps this works for your case?

^[0-9a-z]+(\.[0-9a-z]+)*$

Regex101

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