I am trying to clear and remove directories from a list of urls in R
What I have:
http:
http:
http:
What I want:
domain.com
sub.domain1.com
domain2.com
I have a little long way to clear the start of the URL
url <- c("http://domain.com/123", "http://www.sub.domain1.com/222","http://www.domain2.com/1233/abc"
cleanurl <- gsub("http://","",url)
cleanurl2 <- gsub("www.","",cleanurl)
(Please let me know if there is an easier way to clean http: // and www.)
Now I am having problems with regex and deleting everything after /at the end. I tried this
cleanurl3 <- gsub("/*","",cleanurl2)
But this is just a removal /, not after it.
Thanks in advance for your help!
Nicom source
share