最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
正则字符串中含有超连接代码
时间:2011-02-13 编辑:简简单单 来源:一聚教程网
要判断字符串中是否有url连接代码,我们正则 @"(http|ftp|https教程)://[w]+(.[w]+)([w-.,@?・^=%&:/~+#]*[w-@?^=%&/~+#])";,下面我们用一个实例来说明。
private list
geturlfromcontent(string content)
{
string regexstr = @"(http|ftp|https)://[w]+(.[w]+)([w-.,@?・^=%&:/~+#]*[w-@?^=%&/~+#])";system.text.regularexpressions.matchcollection mc = system.text.regularexpressions.regex.matches(content, regexstr, system.text.regularexpressions.regexoptions.ignorecase);
list
urlstr = new list ();
for (int i = 0; i < mc.count; i++)
{
if(!urlstr.contains(mc[i].tostring()))
{
urlstr.add(mc[i].tostring());
}
}
return urlstr;
}
-
上一个: 判断用户输入为数字函数
-
下一个: asp.net Word文档下载代码
相关文章
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18
- .Net反向代理组件Yarp用法介绍 10-10
- .NET使用YARP通过编码方式配置域名转发实现反向代理教程 10-10