如:http://www.test.net/scripts/index.php?ID=15
http://test.net/scripts/index.php?ID=236
要求找出这种规则的字符串 其中ID参数不固定,也不知道是多少位,http://www.test.net/scripts/index.php?PC=1&KE=ulvmpxik
http://test.net/scripts/index.php?PC=1&KE=ulafecdgf
要求找出这种规则的字符串 其中PC参数不固定,也不知道是多少位,KE参数也不固定 也不知是多少位
http://test.net/scripts/index.php?ID=236
要求找出这种规则的字符串 其中ID参数不固定,也不知道是多少位,http://www.test.net/scripts/index.php?PC=1&KE=ulvmpxik
http://test.net/scripts/index.php?PC=1&KE=ulafecdgf
要求找出这种规则的字符串 其中PC参数不固定,也不知道是多少位,KE参数也不固定 也不知是多少位
解决方案 »
- 给datagridview的datasource赋值后,datagridview.Rows.Count还是0
- 表数据浏览及筛选控件问题
- 删除在DataGridView中的数据
- C# 操作 excel 的问题
- .net项目制作成一个安装文件
- SpVoice是微软库里面的一个类,现在我要写一个类继承SpVoice并且重写Speak方法
- C#线程的一个问题
- C#怎样修改二进制文件中的数据?
- 关于访问浏览器的问题
- EXCEL.dll UsedRange.Cells.Rows.Count有问题???
- 再问一个关于字符串替换,跟正则有关!请高手来指导下
- Application.Run() 和 System.Windows.Forms.Form.ShowDialog() 方法的区别
前半段:"http://www.abc123.com.cn/m"这个格式是固定的,后面"def123"是不一定的,但绝对会大于三位,求这么一个正则,谢谢.第二个是,http://def123.service.abc123.com/
是以"http://"开头,以"service.abc123.com"结尾,中间“def123”是不确定的,但绝对会大于三位,不知该怎么写,谢谢大家了。一直在线。望不吝指教。$str = "http://www.abc123.com.cn/m/def23";
preg_match("/^http.*www.abc123.com.cn/m/(w{3,})/is",$str,$m);
print_r($m);
$str2 = "http://def123.service.abc123.com/";
preg_match("/^http://(w{3,}).service.abc123.com/$/",$str2,$m2);
print_r($m2);
希望这个对你有帮助!
我从网上找到了匹配url的正则表达式如下:
http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
http://(www\.)?test\.net/scripts/index\.php\?ID=\d+
如果不确定,用
http://(www\.)?test\.net/scripts/index\.php\?ID=[^\s]+下面的用
http://(www\.)?test\.net/scripts/index\.php\?PC=\d+&KE=\w+
或者
http://(www\.)?test\.net/scripts/index\.php\?PC=.+?&KE=[^\s]+
http://test.net/scripts/index.php?ID=236
这个要最后是以数字结束 并且含有ID这个参数的呀 http://www.test.net/scripts/index.php?PC=1&KE=ulvmpxik
http://test.net/scripts/index.php?PC=1&KE=ulafecdgf 这个就按一般的URL规则,但是必须要有PC和KE在里面的呀
算了,就用这两个吧
http://(www\.)?test\.net/scripts/index\.php\?ID=\d+
http://(www\.)?test\.net/scripts/index\.php\?PC=.+?&KE=\w+有不符合的再提出来