Using Regex I need to remove the last folder from a path:
Example : C:\Temp\Dir1\
Output : C:\Temp\
Please don't suggest that I can do this with c# or other programming language. I really do need the regex for this.
Thanks in advance for the help.
Replace
[^\\]+\\?$
by nothing. This works for paths like C:\Temp\Dir1
(no trailing backslash) as well. It fails for the root directory of a drive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With