String url = "http://www.google.com"; Pattern pcleanurl = Pattern.compile("regex"); Matcher mcleanurl = pcleanurl.matcher(url); mcleanurl.replaceAll("");
How do I remove anything before and after Google? I understand sometimes there won't be http, sometimes there won't be www. But what would be the method of getting just the domain from the URL?
I did a little looking in pattern matcher and found a replaceAll. It seems a little out of the ordinary to have to perform matching/substitions in this manner at all when in some others it's a built-in function.
my $url = "http://www.google.com"; $url =~ s/http://; $url =~ s/www\.://>/;
The above isn't perfect nor complete but it's so simple to remove anything from a string.