javascript get filename from string -


i want first part of filename full filename, example, from:

bee_gees_-_stayin_alive.mp3 

i want return: bee_gees_-_stayin_alive

how can it?

var filename = file.name; var name = filename.split('.'); var lastarray = name.length; var names = filename.split('.')[lastarray]; 

get index of last period in string , part of string before that.

example:

var fullname = "bee_gees_-_stayin_alive.mp3";  var name = fullname.substr(0, fullname.lastindexof('.')); 

demo: http://jsfiddle.net/sfb2v/


Comments

Popular posts from this blog

html - jquery - p element wont show after I hid it -

python - BeautifulSoup: How to get the nearest tag -

php - Return Last Insert ID with PDO -