0

I have a TextView and a String. The String is to collect what Url may be present in the WebView. The TextView displays the Url so that you have an idea on what website you are on. Im trying to have so that it has the root of the Url. Say you are at "Google.ca" it will display "https://www.Google.ca", though I would like it to display "Google.ca". I have searched for a few days regarding this issue and have only found questions regarding, if they know what will be displayed. For me the String "Url" will be changing and you don't know the exact size nor characters. How would I be able to remove just the "https://www." and anything after the ".", this isn't really a issue its more aesthetically pleasing to me.

EquiWare
  • 127
  • 2
  • 14
  • 2
    you can use `.split(".")` to achieve that. search for it – Abdul Kawee Feb 15 '18 at 11:24
  • 1
    use `split()` and `replaceAll()` for achieve this. – Hemant Parmar Feb 15 '18 at 11:25
  • These are getting a warning of it being ignored, could you provide a example – EquiWare Feb 15 '18 at 11:32
  • `URI uri = new URI("https://www.Google.ca"); String domain = uri.getHost(); domain = domain.startsWith("www.") ? domain.substring(4) : domain;` – Somesh Kumar Feb 15 '18 at 11:34
  • String url = "https://www.Google.ca"; String[] split = url.split("\\."); String finalText = ""; for (int i = 1; i <= split.length-1; i++) { finalText=finalText+split[i]+"."; } finalText = finalText.substring(0, finalText.length() - 1); Toast.makeText(getApplicationContext(), finalText, 0).show(); – SahdevRajput74 Feb 15 '18 at 11:47

0 Answers0