I am selecting an item from arraylist
ArrayAdapter.getItem(which)
I am getting the result as Amazon.com%2C%20Inc.-AMZN
I just want the last part that is AMZN of this string to append in my url.
I am selecting an item from arraylist
ArrayAdapter.getItem(which)
I am getting the result as Amazon.com%2C%20Inc.-AMZN
I just want the last part that is AMZN of this string to append in my url.
Normal String operation like lastIndexOf and substring
String str = "Amazon.com%2C%20Inc.-AMZN";
String result = str.substring(str.lastIndexOf("-") + 1);
System.out.println(result);
or if there are no other -
in the String use
String endBit = str.split ("-")[1];
Please refer this url
How to get a string between two characters?
String s = "Amazon.com%2C%20Inc.-AMZN";
String result = s.substring(s.indexOf("-") + 1);
System.out.println(result);
Output: AMZN
try this.
if there is no other -
String val = "Amazon.com%2C%20Inc.-AMZN";
String arr[]=val.split("-");
and at index 1 you can get your value.
like arr[1]// this will contain "AMZN"