Url string processing: what is the best way?
I don't think you need any ML, in the best case it's going to be very slow compared to direct processing and it's very likely to cause errors. 

For each address you can parse the url string and extract the domain substring (in your example they are all prefixes, if it's always the case it's very easy). Then you just group them by domain in a map... done.