How can I remove \"www\", \"http://\", \"https://\" from strings using Ruby?
I tried this but it didn\'t work:
s.gsub(\'/(?:http?:\\/\\/)?(?:www\\.)?
def strip_url(target_url)
target_url.gsub("http://", "")
.gsub("https://", "")
.gsub("www.", "")
end
strip_url("http://www.google.com")
=> "google.com"
strip_url("https://www.google.com")
=> "google.com"
strip_url("http://google.com")
=> "google.com"
strip_url("https://google.com")
=> "google.com"
strip_url("www.google.com")
=> "google.com"