What is the fastest way to get the domain/host name from a URL?

前端 未结 8 951
不知归路
不知归路 2020-12-08 15:48

I need to go through a large list of string url\'s and extract the domain name from them.

For example:

http://www.stackoverflow.com/questions

8条回答
  •  既然无缘
    2020-12-08 16:27

    You could try to use regular expressions.

    http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html

    Here is a question about extracting domain name with regular expressions in Java:

    Regular expression to retrieve domain.tld

提交回复
热议问题