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

140
Vistas
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 Respuestas
Responde la pregunta

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 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