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

263
Views
¿Cómo eliminar el nombre de archivo de una ruta con solo JS?

Estaba buscando en todas partes una forma de eliminar solo el nombre de archivo de una ruta con JS, pero solo encuentro información sobre cómo eliminar la ruta y mantener el nombre de archivo. tengo este camino:

C:\Users\usuario\Desktop\CyT\Proyectos\AlmPas\2022-06-17\luis@gmail.com\1234567890.zip

Pero entonces, solo necesito la ruta:

C:\Users\usuario\Desktop\CyT\Proyectos\AlmPas\2022-06-17\luis@gmail.com\

Si uso el siguiente código, solo obtengo el nombre del archivo, pero ¿cómo puedo obtener la ruta sin el nombre del archivo?

 soloArchivo = ruta_archivos.replace(/^.*[\\\/]/, '')
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Extraiga con esta expresión regular:

 const str = String.raw`C:\Users\usuario\Desktop\CyT\Proyectos\AlmPas\2022-06-17\luis@gmail.com\1234567890.zip` const regex = /^.*[\\\/]/; const match = str.match(regex); if (match) { console.log(match[0]) } else { console.log("Sorry, there is no match.") }

Resultados : C:\Users\usuario\Desktop\CyT\Proyectos\AlmPas\2022-06-17\luis@gmail.com\

EXPLICACIÓN DEL PATRÓN

 -------------------------------------------------------------------------------- ^ the beginning of the string -------------------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible)) -------------------------------------------------------------------------------- [\/] any character of: '\/'
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!