var fileUrl = "blah/filename.zip", parts, ext = ( parts = fileUrl.split("/").pop().split(".") ).length > 1 ? parts.pop() : ""; alert( ext );