手机
当前位置:查字典教程网 >编程开发 >C#教程 >C#实现自动识别URL网址的方法
C#实现自动识别URL网址的方法
摘要:本文实例讲述了C#实现自动识别URL网址的方法。分享给大家供大家参考。具体实现方法如下:usingSystem;usingSystem.Co...

本文实例讲述了C#实现自动识别URL网址的方法。分享给大家供大家参考。具体实现方法如下:

using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Text.RegularExpressions; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { string s = "例如:http://www.asd.com"; Regex re = new Regex(@"(?<url>http(s)?://([w-]+.)+[w-]+(/[w- ./"); MatchCollection mc = re.Matches(s); foreach (Match m in mc) { s=s.Replace(m.Result("${url}"), String.Format("<a href='{0}'>{0}</a>", m.Result("${url}"))); } Console.WriteLine(s); } } }

希望本文所述对大家的C#程序设计有所帮助。

【C#实现自动识别URL网址的方法】相关文章:

C#调用Java类的实现方法

c#实现输出本月的月历

c#之利用API函数实现动画窗体的方法详解

C# 格式化字符首字母大写的方法

.net后台获取html控件值的2种方法

C#中Web.Config加密与解密的方法

c#启动EXE文件的方法实例

c#模拟平抛运动动画的方法详解

C# 抓取网页内容的方法

C#实现通过程序自动抓取远程Web网页信息的代码

精品推荐
分类导航