Is there a way that I can get the last value (based on the \'\\\' symbol) from a full path?
Example:
C:\\Documents and Settings\\img\\recycled log.jpg<
This solution is much simpler and generic, for both 'file name' and 'path'.
const str = 'C:\\Documents and Settings\\img\\recycled log.jpg';
// regex to split path to two groups '(.*[\\\/])' for path and '(.*)' for file name
const regexPath = /^(.*[\\\/])(.*)$/;
// execute the match on the string str
const match = regexPath.exec(str);
if (match !== null) {
// we ignore the match[0] because it's the match for the hole path string
const filePath = match[1];
const fileName = match[2];
}