I have a word such as
var text = 'http://xxx:9696/images/FSDefault.jpg';
How to get only the word FSDefault.jpg
I have a word such as
var text = 'http://xxx:9696/images/FSDefault.jpg';
How to get only the word FSDefault.jpg
Use String#split method to split based on delimiter / and get the last element of the array using Array#pop method.
var text = 'http://xxx:9696/images/FSDefault.jpg';
console.log(text.split('/').pop())
String#lastIndexOf method along with String#substr method.
var text = 'http://xxx:9696/images/FSDefault.jpg';
console.log(text.substr(text.lastIndexOf('/') + 1))
This is pretty verbose but conveys the logic.
var text = 'http://xxx:9696/images/FSDefault.jpg';
var parts = text.split('/'); // Split the string into an array of strings by character /
var lastIndexOf = parts.length - 1; // Determine the last word's 0-based index in array (length -1)
var last = parts[lastIndexOf]; // Grab the last part of the array.
alert(last); // Alerts FSDefault.jpg