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

134
Visualizações
extract last portion from url

Having the following link: /C:\Users\xxx\Desktop\yyy\public\assets\1634648850202.jpg

How do i extract 1634648850202.jpg?

i tried:

const lastplace = thisUrl.substring(thisUrl.lastIndexOf("\"));

This does not work, because the backslash is recognized as a functional character (is this the right term?)

Here are 2 Questions from my side:

  1. how do i extract the last part?
  2. how should i handle backslashes in general?
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Common way:

thisUrl.split(/\/|\\/).pop() // 1634648850202.jpg

I also recommend to split url/path by both slashes (/,\) 'cause of different enviromnents/systems uses diffrent character.

UPD: just make your \ double to handle it (you're right, it's a escape character), like this:

''.lastIndexOf('\\')

Also you need do the same when you initiate your string:

const thisUrl = '/C:\\Users\\xxx\\Desktop\\yyy\\public\\assets\\1634648850202.jpg';
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