I have the following code:
var fileName = "C:\fakepath\a.jpg";
fileName = fileName.replace(/.*(\/|\\)/, '')
and this will return just the a.jpg as intended but I don't understand how it knew to replace the the characters between both of "\" such as the substring "fakepath". From what I see it should just replace the first character "C" because of the period and then any appearances of "/" or "\" with "".