-2

I got the following string from a Json:

image/folder/folder/xxx.jpg

I would like to explode the xxx.jpg and keep it to local var.

thanks

Scopi
  • 663
  • 1
  • 6
  • 21

1 Answers1

0

Split it using String#split method and get the last value from the array using Array#pop method.

var string = " image/folder/folder/xxx.jpg";

var res = string.split('/').pop();

console.log(res);
Pranav C Balan
  • 113,687
  • 23
  • 165
  • 188