0

I have a string variable in Java with the value below:

String str = "web > data > list > new_list.html";

I want my final string like so:

String str = "new_list.html";

I have tried like this:

final Pattern pattern = Pattern.compile("[\\>.]");
final String[] result = pattern.split(str);

But it is returning data > list > new_list.html

How can i get exact substring new_list.html?

Toastrackenigma
  • 7,604
  • 4
  • 45
  • 55
Hari
  • 13
  • 2
  • Does this help ? https://stackoverflow.com/questions/12595019/how-to-get-a-string-between-two-characters/18096365#18096365 – Heniam May 07 '20 at 03:35
  • 1
    Does this answer your question? [How to get a string between two characters?](https://stackoverflow.com/questions/12595019/how-to-get-a-string-between-two-characters) – Heniam May 07 '20 at 03:36

2 Answers2

1
String s =  "web > data > list > new_list.html";

String newList = s.substring(s.lastIndexOf("> ") + 2);

PatrickChen
  • 1,350
  • 1
  • 11
  • 19
0

Try this:

String str = "web > data > list > new_list.html";
str = str.substring(20);
Dumidu Udayanga
  • 864
  • 2
  • 9
  • 21