Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda