-1

I have a string which is

file:///storage/emulated/0/Android/data/com.myapp/files/Pictures/00cb3b0b-45d5-486b-8f33-0fa3bf2285ff.jpg

And I want to extract the string after the last / which will be 00cb3b0b-45d5-486b-8f33-0fa3bf2285ff.jpg

How can I extract the last part of this string and store it in a variable ?

Mehdi Faraji
  • 2,574
  • 8
  • 28
  • 76
  • 2
    Does this answer your question? [Last segment of URL in jquery](https://stackoverflow.com/questions/4758103/last-segment-of-url-in-jquery). `filename.substring(filename.lastIndexOf('/') + 1)` – slashroot Nov 15 '21 at 20:20
  • `str.split('/')[str.length-1]` – Randy Casburn Nov 15 '21 at 20:21

1 Answers1

0

I extracted the last part of string like this :

mystring.substring(mystring.lastIndexOf('/') + 1)
Mehdi Faraji
  • 2,574
  • 8
  • 28
  • 76