For this particular problem, I would not use regular expressions. It would be more elegant (and provide more robust validation) to instantiate a URL
object using the spec String
that you have and then calling the URL object's getHost()
method.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…