I've cobbled together the following and it's working fine :
$('#url').val(filename.slice(0, -4).toLowerCase().replace(/[^\w\s]/gi, '').replace(/\s+/g, '-'));
But it's just so ugly. Can anybody suggest a cleaner way to do this?
What's happening :
1) strip the last 4 chars (.ext) from the filename from a fileinput
2) convert to lowercase
3) replace all non-alphanumeric characters except whitespace
4) replace whitespace with a hypen
End result is something like : my-wonderful-file
Can anybody make this look like less of a pig's ear?