由网友(与风相拥)分享简介:我写的正则表达式来验证URL可能是要么喜欢I have written regex to validate URL which could be either likegoogle.comwww.google.comhttp://www.google.comhttps://www.google.com我已经用Re...
我写的正则表达式来验证URL可能是要么喜欢
I have written regex to validate URL which could be either like
google.com
www.google.com
http://www.google.com
https://www.google.com
我已经用
Regex urlRx = new Regex(@"^(http|ftp|https|www)://([w+?.w+])+([a-zA-Z0-9~!@#$%^&*()_-=+/?.:;',]*)?$", RegexOptions.IgnoreCase);
它适用于HTTP和放大器; https.It是不工作的谷歌/ COM和放大器。 www.google.com。
It works for http & https.It is not working for google./com & www.google.com.
请帮我解决这个问题。
感谢
推荐答案
无需使用正则表达式恕我直言 - 尝试
no need for a regex IMHO - try
Uri.IsWellFormedUriString(YourURLString, UriKind.RelativeOrAbsolute)
请参阅 MSDN
相关推荐
最新文章