0
我想驗證一個URL的語法。我應該如何使用正則表達式來測試像www.chaine.com
這樣的URL的有效性?Java:Regex驗證URL
我想驗證一個URL的語法。我應該如何使用正則表達式來測試像www.chaine.com
這樣的URL的有效性?Java:Regex驗證URL
你能做到這樣,沒有正則表達式:
public boolean validateURI(String uri)
{
try
{
new URI(uri);
return true;
} catch(Exception e)
{
return false; // MalformedURI Exception, is the name I think
}
}
URL extends URI
,你可以說,我想......