Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
extraer la última parte de la url

Teniendo el siguiente enlace: /C:\Users\xxx\Desktop\yyy\public\assets\1634648850202.jpg

¿Cómo 1634648850202.jpg ?

Lo intenté:

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

Esto no funciona, porque la barra invertida se reconoce como un carácter funcional (¿es este el término correcto?)

Aquí hay 2 preguntas de mi parte:

  1. ¿Cómo extraigo la última parte?
  2. ¿Cómo debo manejar las barras invertidas en general?
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Forma común:

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

También recomiendo dividir la url/ruta por ambas barras ( / , \ ) porque los diferentes entornos/sistemas usan caracteres diferentes.

UPD: solo haz tu \ doble para manejarlo (tienes razón, es un carácter de escape), así:

 ''.lastIndexOf('\\')

También debe hacer lo mismo cuando inicia su cadena:

 const thisUrl = '/C:\\Users\\xxx\\Desktop\\yyy\\public\\assets\\1634648850202.jpg';
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!