There is a task to trim a string with a hypertext link using Java tools.
For example from the line:
http://academy.it.ru/courses/?COUNT_3=1000000&arrFilter[CITY]=&arrFilter[PROPERTY_NAPR_CATALOG] or
http://www.academy.it.ru/courses/?COUNT_3=1000000&arrFilter[CITY]=&arrFilter[PROPERTY_NAPR_CATALOG] need to make a string like:
www.academy.it.ru I think I need to find // and the closing slash / . But how to implement this in the code for me is not clear. It is also not clear how to distinguish a single slash from a double one and from the rest of the slashes in the string.
Here is what I implemented:
String findhtext=""; try{ XmlPullParser xpp = prepareXpp(); if (xpp.getText().contains("http://"||"https://")) findhtext=xpp.getText().substring(indexOf("//"),indexOf("/")) ; } But Android Studio swears that it cannot recognize the IndexOf method. I'm new to java.
What can be done to trim the link as required?
str.indexOfwherestris the string you are looking for. - pavelxpp.getText().indexOf... - pavelindexOfreturns the position, and you apparently immediately put in the line. - pavel