Regular expression to remove a file’s extension

Just for completeness: How could this be achieved without Regular Expressions?

var input="myfile.png";
var output = input.substr(0, input.lastIndexOf('.')) || input;

The || input takes care of the case, where lastIndexOf() provides a -1. You see, it’s still a one-liner.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)