使用一个不错的正则表达式来配对一个正确的url.

string reg = @"(?i)(http://|https://)?(\w+\.){1,3}(com(\.cn)?|cn|net|info|org|us|tk)\b"; 比较通用
            string reg = @"(?i)(http://|https://)?(\w+\.){1,3}(com(\.cn)?|cn|net|info|org|us|tk)\b";
Regex r = new Regex(reg); textEditUrl.Text = textEditUrl.Text.Trim();
Match match = r.Match(textEditUrl.Text);
if (!match.Success)
{
CustomControls.MessageErrDlg dlg = new CustomControls.MessageErrDlg();
dlg.Text = "Remote Command Failed";
dlg.ShowDialog(); textEditUrl.Text = "http://";
}

匹配URL的更多相关文章

  1. 正确匹配URL的正则表达式

    网上流传着多种匹配URL的正则表达式版本,但我经过试验,最好用的还是从stackoverflow上查到的: (https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_| ...

  2. *****正则表达式匹配URL

    最近将匹配URL的正则替换了下 之前的是: ((http|ftp|https)://)(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3 ...

  3. java 中 正则 正则表达式 匹配 url

    不多说 [http|https]+[://]+[0-9A-Za-z:/[-]_#[?][=][.][&]]* 这个就是匹配 网络上的网址 又称 url . 最起码 绝大部分的taobao ur ...

  4. Python 使用正则表达式匹配URL网址

    使用正则表达式匹配以 .com 或 .cn 为域名后缀的URL地址 In [1]: import re In [2]: str = "http://www.baidu.com/" ...

  5. 匹配url - 正则表达式

    /^\/(.+)\/$/g.exec(req.url)

  6. 正则匹配url中的query参数信息

    var url = 'name=xiaoming&age=10&school=xinhua'; var reg = /([^&=]+)=?([^&]*)/g;

  7. Django基于正则表达式匹配URL

    在Django1.X中,是这样匹配的. 在Django2.X中,是这样匹配的. Django2.X中开始需要用re_path模块进行正则表达式匹配了,太JB坑了,卡了好久这个问题,最后还是问群里面的高 ...

  8. 正则表达式匹配URL或者网址

    正则表达式 (http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])? ...

  9. Nginx使用Location匹配URL进行伪静态

    基础知识 Nginx location 配置语法 1. location [ = | ~ | ~* | ^~ ] uri { ... } 2. location @name { ... } locat ...

随机推荐

  1. QMessageBox对话框

    infoBox = QMessageBox() infoBox.setIcon(QMessageBox.Question) infoBox.setWindowTitle("初始化失败&quo ...

  2. 理解不为人知的ClassLoader

    JAVA类装载方式,有两种: 1.隐式装载, 程序在运行过程中当碰到通过new 等方式生成对象时,隐式调用类装载器加载对应的类到jvm中. 2.显式装载, 通过class.forname()等方法,显 ...

  3. maven中央仓库地址(支持db2,informix等)

    maven中央仓库地址(以下设置写在pom.xml文件里): <repositories> <repository> <id>nexus</id> &l ...

  4. 利用python解析地址经纬度和利用经纬度定位地址

    解析地址经纬度 from geopy.geocoders import Nominatim try: geolocator = Nominatim() location = geolocator.ge ...

  5. vue 父子组件通信-props

    父组件:引用了ComBack组件 ComBack组件:引用了BasicInfor组件 先使用props获取父组件的headInfo这个对象,这里注意(default)默认返回值要用工厂形式返回 Bas ...

  6. [luogu P3313] [SDOI2014]旅行

    [luogu P3313] [SDOI2014]旅行 题目描述 S国有N个城市,编号从1到N.城市间用N-1条双向道路连接,满足从一个城市出发可以到达其它所有城市.每个城市信仰不同的宗教,如飞天面条神 ...

  7. 【转】FluentAPI详细用法

    设置主键modelBuilder.Entity<x>().HasKey(t => t.Name); 设置联合主键modelBuilder.Entity<x>().HasK ...

  8. mysql 执行sql流程

    客户端发送sql 语句后的堆栈 #0 0x0000000100370565 in do_command(THD*) at percona-server-Percona-Server-5.6.37-82 ...

  9. 微信小程序<swiper-item>标签中传入多个数组型数据的方法(小程序交流群:604788754)

    在<swiper-item>中用for循环传入多个成对不同数据时的实现方法. 效果如下: 遍历实现方法:wxss省略: wxml中代码: <!--导航部分轮播图--> < ...

  10. Daily record-October

    October 11. Hope is a good thing, maybe the best of things, and no good thing ever dies. 希望是美好的,也许是人 ...