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

183
Vistas
Regex detect last character slash and and ?id=

This is my Javascript regex ^.*(?<!\/)$ that checks if the URL is not ending with (/) slash

detects: /play/popular ok: /play/popular/

How can I detect if the URL is not ending with / and does not include ?id= ?

detects: play/popular catch: play/popular/?id=448

debugger: https://regex101.com/r/sSDIic/2

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

0

One way is to extend the negative lookbehind to optionally add the id= followed by 1 or more digits.

^.*$(?<!\/(?:\?id=\d+)?)

Regex demo

It might be easier to rule out id= in the string using a negative lookahead, and match a non whitespace char at the end being not a /if it can not end on a space.

^(?!.*\?id=).*[^\s/]$

Regex demo

Note that .* also match spaces, to match only non whitespace characters you can use \S*

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