常规的前pression验证URL

编程入门 行业动态 更新时间:2024-10-25 16:28:03
本文介绍了常规的前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

本文发布于:2023-06-10 16:28:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/615034.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:常规   pression   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!