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...?
To match a character having special meaning in regex, you need to use a escape sequence prefix with a backslash ( \ ). E.g., \. matches "." ; regex \+ matches "+" ; and regex \( matches "(" . You also need to use regex \\ to match "\" (back-slash).
Backslash is an escape character in regular expressions. You can use '\\' to refer to a single backslash in a regular expression. However, backslash is also an escape character in Java literal strings. To make a regular expression from a string literal, you have to escape each of its backslashes.
The backslash character ( \ ) is the escaping character. It can be used to denote an escaped character, a string, literal, or one of the set of supported special characters. Use a double backslash ( \\ ) to denote an escaped string literal.
The backreference \1 (backslash one) references the first capturing group. \1 matches the exact same text that was matched by the first capturing group. The / before it is a literal character. It is simply the forward slash in the closing HTML tag that we are trying to match.
What about
<cfset fileName = GetFileFromPath("\\server\folder_A\folder_B\etc\more.mov") />
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