I would like to find the last folder in a path. Ex:
G:\DATA1\DATA2\DATA3\DATA4\my target\file.xxx
I need to extract my target. I tried (^.*\\)(.*\\)
but the result is my target\
. Someone can fix it?
Use the power of greedy operator along with capturing group.
.*\\([^\\]+)\\
OR
Use the same regex but get out of the last backslash from the second capturing group.
.*\\(.*)\\
Get the string you want from group index 1.
DEMO
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