关于给网址加上链接的--正则表达式 你这个功能实现起来应该说比较简单,但问题是你的源字符串是什么形式的,我该如何从源字符串中判断,哪一个或多个字符串是我要转换的也就是,我该如何从你的源字符串中识别www.abc.com、http://www.abc.com、abc.com这三种形式 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string strContent = InputTextBox.Text;Regex urlregex = new Regex(@"(http:\/\/([\w.]+\/?)\S*)",RegexOptions.IgnoreCase| RegexOptions.Compiled);strContent = urlregex.Replace(strContent,"<a href="" target="_blank"></a>");Regex emailregex = new Regex(@"([a-zA-Z_0-9.-]+@[a-zA-Z_0-9.-]+\.\w+)",RegexOptions.IgnoreCase| RegexOptions.Compiled);strContent = emailregex.Replace(strContent, "<a href=mailto:></a>");lbContent.Text += "<br>"+strContent;这个好象不行,大家帮我看看 随便写了一个,只是处理了.com的情况,楼主不回我问题,我也没辙string yourStr = ...........;string resultStr = Regex.Replace(yourStr, @"(http://)?(www.)?([\w-]+\.com)", new MatchEvaluator(regReplace), RegexOptions.IgnoreCase);private string regReplace(Match m){ if(m.Value.StartsWith("http://")) { return "<a href='"+m.Value+"'>"+m.Value.Remove(0,7)+"</a>"; } else if(m.Value.StartsWith("www")) { return "<a href='http://"+m.Value+"'>"+m.Value+"</a>"; } else { return "<a href='http://www."+m.Value+"'>www."+m.Value+"</a>"; }} 按钮的可用性 求PDF417的DLL或源码 c#线程问题 问个最基础的问题,类定义个属性,这段代码里get里value.. C#网络编程方面的资料,主要是UdpClient 彼人遇到一个问题请教各位,存储过程怎样防止注入式错误(送分不是问题) DOTMSN显示中文联系人的名字为问号,咋办呢? 新年快乐!送分2 [求助]如何用C#实现word中的打印预览和打印的功能 关于提交数据总是出错,烦! treeview图标不能显示 DATASET怎么向EXCEL导出两张表~~
Regex urlregex = new Regex(@"(http:\/\/([\w.]+\/?)\S*)",
RegexOptions.IgnoreCase| RegexOptions.Compiled);
strContent = urlregex.Replace(strContent,
"<a href="" target="_blank"></a>");
Regex emailregex = new Regex(@"([a-zA-Z_0-9.-]+@[a-zA-Z_0-9.-]+\.\w+)",
RegexOptions.IgnoreCase| RegexOptions.Compiled);
strContent = emailregex.Replace(strContent, "<a href=mailto:></a>");
lbContent.Text += "<br>"+strContent;这个好象不行,大家帮我看看
string resultStr = Regex.Replace(yourStr, @"(http://)?(www.)?([\w-]+\.com)", new MatchEvaluator(regReplace), RegexOptions.IgnoreCase);
private string regReplace(Match m)
{
if(m.Value.StartsWith("http://"))
{
return "<a href='"+m.Value+"'>"+m.Value.Remove(0,7)+"</a>";
}
else if(m.Value.StartsWith("www"))
{
return "<a href='http://"+m.Value+"'>"+m.Value+"</a>";
}
else
{
return "<a href='http://www."+m.Value+"'>www."+m.Value+"</a>";
}
}