用于验证url的正则表达式 [英] Regular expression to validate url

查看:98
本文介绍了用于验证url的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮我验证使用正则表达式的网址

它应该验证这些类型的网址



http:/ /www.codeproject.com



https://www.codeproject.com/quetions



www .codeproject.co.in



它不应该允许4 w

解决方案

试试这个网站。希望对您有所帮助。



http://regexlib.com /Search.aspx?k=url [ ^ ]


谷歌是你的朋友:好好经常拜访他。他可以比在这里发布问题更快地回答问题......



快速搜索 使用您的主题作为搜索词 提供超过175万次点击: Google [ ^ ]



将来,请尝试自己做至少基础研究,不要浪费你的时间或我们的时间。


Bad想法。域名如wwww.mySite.tld(是的,4'w')可以有效。为了确保它是这样,获得一些Web托管,获得自己的一些域名,并创建一个子域wwww。它会起作用,我保证。



(tld我的意思是顶级域名,例如com,org, net,edu等)



同时,像http://www.mySite.tld这样的好网址可以是无效。因此,即使您可以轻松执行此验证,也不会提出此类问题,这种验证将毫无用处。



-SA

Can any one please help me validate the url by using regular expression
it should validate these type of urls

http://www.codeproject.com

https://www.codeproject.com/quetions

www.codeproject.co.in

it should not allow 4 w's

解决方案

Try this site. Hope it helps you.

http://regexlib.com/Search.aspx?k=url[^]


Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...

A very quick search using your subject as the search term gave over 1.75 million hits: Google[^]

In future, please try to do at least basic research yourself, and not waste your time or ours.


Bad idea. Domain name like "wwww.mySite.tld" (yes, with 4 'w') can be valid. To make sure it's so, get some Web hosting, obtain some domain name of your own and create a sub-domain "wwww". It will work, I'll guarantee it.

(By "tld" I mean "top-level domain", such as "com", "org", "net", "edu", etc.)

At the same time, "good" URL like "http://www.mySite.tld" can be invalid. So, this validation would be pretty much useless, even though you could easily perform it, without asking such questions.

—SA


这篇关于用于验证url的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆