javascript - Get last word js -


this removes last word. how last word (stripe)?

var baseshirturl = "base shirt draped fabric stripe"; baseshirturl = baseshirturl.substring(0, baseshirturl.lastindexof(" ")); alert(baseshirturl); 

to last word:

baseshirturl.split(' ').pop(); 

and remove last word can this:

baseshirturl = baseshirturl.replace(/\w+$/,''); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -