天天看點

判斷字元串是否 是url

public

static

bool

IsUrl(

string

url)

{

return

Regex.IsMatch(url, 

@"^(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\.))+(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9\&%_\./-~-]*)?$"

,

RegexOptions.IgnoreCase);

}