本文介绍了常规的前pression验证URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问:我想一个普通的前pression验证URL,但我想,让这个字符(〜)的蒂尔达
Q: I want a regular expression to validate the URL but i wanna to allow this character(~)the Tilda
这样的网址:
stackoverflow/questions/~/ 让 HTTP 或不 HTTP
在此先感谢
修改
我终于找到一个完美的一种:(http|ftp|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?但我想,以允许用户与协议输入URL或没有它prevent混淆如何做到这一点。
i find a perfect one finally: (http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])? but i wanna to allow the user to enter the url with the protocol or without it to prevent any confusion how to do that.
推荐答案要允许非连续的波浪线:
To allow non-consecutive tildes:
\w+([-+.'~]\w+)*要允许任何地方波浪线:
To allow tildes anywhere:
[\w~]+([-+.'][\w~]+)*更多推荐
常规的前pression验证URL
发布评论