How to reliably get the filename without the suffix in javascript?
问题 Whats the reliable way on getting the filename of a file by removing suffix in javascript? I have a file let's say : http://example.com/uploads/images/a51dd42_thumb.jpg and http://example.com/uploads/images/a51dd42_s.jpg Now i want to get the string http://example.com/uploads/images/a51dd42.jpg replace() function is not what i want since images filename could have many different types of suffixes Maybe regex is the best for this? If yes, whats the reliable code for it? Thanks in advance 回答1: