All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
利用正则表达式自动给Email地址和Url加上连接_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/6 9:10:11 Browse times: 332 Comment times: 0

利用正则表达式自动给Email地址和Url加上连接_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

利用正则表达式自动给Email地址和Url加上连接_[Asp.Net教程]

using System;

using System.Text.RegularExpressions;

namespace CommLayer

{

///

/// 自动给邮件地址或email地址加上url

///

public class HyperlinkUrl

{

private static Regex urlregex = new Regex(@"(http:\/\/([\w.]+\/?)\S*)",

RegexOptions.IgnoreCase|RegexOptions.Compiled);

private static Regex emailregex = new Regex(@"([a-zA-Z_0-9.-]+\@[a-zA-Z_0-9.-]+\.\w+)",

RegexOptions.IgnoreCase|RegexOptions.Compiled);

public HyperlinkUrl()

{

}

///

/// 生成带连接的字符串

///

/// 需要生成带连接地址的字符串

/// 经过转换的字符串

public static string GenHyperlinkUrl(string link)

{

link = emailregex.Replace(link, "1");

link = urlregex.Replace(link, "1");

return link;

}

}

}





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.