my problem is that I have a string called url which has an extructure like the following https://www.ejemplo.com.co, and I need to extract only the text after "https: // www.", that is what I serves is "ejemplo.com.co", of course I do not know the url as it changes constantly.
Asked
Active
Viewed 244 times
0
-
Hint: look at the `split` and `substring` methods. – Mar 06 '18 at 16:43
1 Answers
0
Use the following:
public String retrieveStr(String url) throws MalformedURLException {
URL aURL = new URL(url);
String desireStr = aURL.getHost().split("\\.")[1];
return desireStr;
}
use this

Mamun Kayum
- 161
- 7
-
Thank you very much, but I would miss a part, taking into account that I already have after the puneto, as I do to only hold the part after the next point. I mean what would happen before the point, eg: ejemplo.com.co, I just want "example" – Nelson Redondo Barros Mar 06 '18 at 18:01
-
-
yes, let's give a practical example, this is the url: https://stackoverflow.com/questions/5414657/, what I want to know is "stackoverflow" – Nelson Redondo Barros Mar 06 '18 at 19:02
-
-