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

126
Vistas
Support Regex that has more than one forward slash in domain

I need to support endpoints such as

/myendpoint:
/v1/myendpoint:
/v3/someotherendpoint:

This regex:

const regexPattern = '/[a-zA-Z0-9-]+:';

Only answers to /myendpoint:

How can we do an or operation to support both cases ?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If you just need to test if it matches or not, you can just use a repeated pattern, like this:

const tests = ['/a', '/a/b/c', 'nope'];
const pattern = /^(\/[0-9a-z-]+)+$/i;

tests.forEach(str => console.log(str, pattern.test(str)));

If you want to match each part, it gets a lot trickier and uglier, and you'd better off testing if it works then just use split('/') to get the parts.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Just make it something like recursive your existing solution for its multiple instance.

Example: (\/[a-zA-Z0-9-]+)*:

Play: https://regexr.com/6jka3

The character * in a regular expression means "match the preceding character zero or many times"

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