I have a dataset containing multiple urls as a string in one column 'urls'
urls <- "https://www.linkedin.com/xx/xxx-xx-xxx/ https//domain.io https://medium.com/@xxxxx"
id <- 1
df <- cbind(data.frame(urls), data.frame(id))
I now want to extract the complete domain matching "linkedin.com" and store it in a new column df$linkedin. And do the same for domain matching "medium.com" and store it in a new column df$medium. So the result would be basically
df$linkedin
"https://www.linkedin.com/xx/xxx-xx-xxx/"
df$medium
"https://medium.com/@xxxxx"
Somehow I have today a bad hair day and don't see an elegant solution. Would be awesome if you can help out me here :)