I’m trying to remove the filename from a path created in C# (using Server.MapPath, which by default uses \\), like :
C:\\Foo\\Bar\\Baz\\file.js
My current regex looks to be somewhat working in RegExr but in the real application it works just the opposite way :
\/[^\\]+$
What am I missing ?
Since you’re doing this in JS just do a
String.splitoperation.The RegEx way…
By the way, the only thing wrong with your original RegEx was the leading \ and the missing /
Would nails it. (the trailing
/gon @JDwyers answer is to make it a global match, that’sredundant for your use case.)
So…
Cheers