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

113
Views
JavaScript Regex para Path sin barras inclinadas iniciales o finales

Estoy luchando por encontrar un patrón Regex para JavaScript que recortará una ruta de sus barras inclinadas anteriores y posteriores (o hashes/extensiones)

Por ejemplo:

 path/ /path /folder/path/ /folder/folder/path /folder/path#hash /folder/path.ext

Debería volver:

 path path folder/path folder/folder/path folder/path folder/path

Sentí que me estaba acercando a lo siguiente, pero solo selecciona texto sin barras, hash o puntos.

 ^([^\\\/\#\.]*)(?![\#\.\\\/].*$)/gm

Estoy tratando de usar esto para Regex en una validación de campo de texto vuetify, si eso es útil.

Resultado

Terminé con esta babosa de expresiones regulares

 /^(?![\#\/\.\$\^\=\*\;\:\&\?\(\)\[\]\{\}\"\'\>\<\,\@\!\%\`\~\s])(?!.*[\#\/\.\$\^\=\*\;\:\&\?\(\)\[\]\{\}\"\'\>\<\,\@\!\%\`\~\s]$)[^\#\.\$\^\=\*\;\:\&\?\(\)\[\]\{\}\"\'\>\<\,\@\!\%\`\~\s]*$/

https://regexr.com/66ol9

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Así es como se logra sin mirar atrás (siguen siendo rechazados en Safari :():

 ^(?![#\/.])(?!.*[#\/.]$).*

Ver prueba de expresiones regulares . Y...

EXPLICACIÓN

 -------------------------------------------------------------------------------- ^ the beginning of the string -------------------------------------------------------------------------------- (?! look ahead to see if there is not: -------------------------------------------------------------------------------- [#\/.] any character of: '#', '\/', '.' -------------------------------------------------------------------------------- ) end of look-ahead -------------------------------------------------------------------------------- (?! look ahead to see if there is not: -------------------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible)) -------------------------------------------------------------------------------- [#\/.] any character of: '#', '\/', '.' -------------------------------------------------------------------------------- $ before an optional \n, and the end of the string -------------------------------------------------------------------------------- ) end of look-ahead -------------------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))
about 4 years ago · Juan Pablo Isaza Report

0

Utilice una mirada hacia delante negativa al principio y una mirada hacia atrás negativa al final.

 /^(?![#\/.]).*(?<![#\/.])$/

MANIFESTACIÓN

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!