Given a file path such as: \\server\folder_A\folder_B\etc\more.mov
I need a regex that'll give me the last backslash so I can extract the actual file name.
My attempt of "$\\" is not returning anything.
I'm using coldfusion.
Suggestions...?
Given a file path such as: \\server\folder_A\folder_B\etc\more.mov
I need a regex that'll give me the last backslash so I can extract the actual file name.
My attempt of "$\\" is not returning anything.
I'm using coldfusion.
Suggestions...?
Do you just want everything after the last backslash (the filename)?
([^\\]+)$
The filename will be contained in the capture.
To match starting at the last backslash you'd do...
\\[^\\]+$
I'm not familiar with coldfusion, but I'm assuming that if it does regular expressions, it does captures as well. If you do really need the position and can get that from the match, the second expression might be what you want.
(Edited for clarity and to answer comment)
Do you absolutely have to use regex? Why not split the string and grab the last element?
<cfset fileName = ListLast(filePath, "\\")>