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

205
Vistas
Need help in writing Regular expression

Can someone help me in writing regular expression to match such kind of string

Rules are:

  1. It should start with nl
  2. It can or cannot have one parameter in between nl and contact (like /abc/) but not ( /abc/def/)
  3. It can have anything after contact

Examples:

nl/abc/contact --> allowed

nl/contact --> allowed

nl/abc/def/contact --> not allowed

nl/abc/contact/mno --> allowed

nl/abc/contactmno/ ---> not allowed

I tried writing one ("^nl(.?)/contact(.)$"), but it has a problem that it allows any number of slashes between nl and contact wheras I just want at max one slash in between

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I would use:

^nl(?:/[^/]+)?/contact(?:/[^/]+)*$

Demo

This pattern says to match:

^            from the start of the path
nl           starts with "nl"
(?:/[^/]+)?  any zero or one path parameter following
/contact     /contact
(?:/[^/]+)*  followed by zero or more other path parameters
$            end of the input
over 4 years ago · Santiago Trujillo 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