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

前端 未结 8 977
不知归路
不知归路 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:37

    You could write a regexp? http:// is always the same, and then match everything until you get the first '/'.

提交回复
热议问题