我试图解析字符串的内容,看看是否字符串包含的URL,以完整的字符串转换为HTML,使串点击。提取字符串分隔符之间的所有子串在一个字符串(C#)
我不知道是否有这样做的更聪明的方式,但我开始尝试创建C#中的字符串分割方法,或Regex.Split解析器。但我找不到一个好办法。
(这是一个ASP.NET MVC应用程序,所以可能有这样的一些更聪明的方式),我想前
。转换字符串;
"Customer office is responsible for this. Contact info can be found {link}{www.customerservice.com}{here!}{link} More info can be found {link}{www.customerservice.com/moreinfo}{here!}{link}"
进入
"Customer office is responsible for this. Contact info can be found <a href=www.customerservice.com>here!</a> More info can be found <a href=www.customerservice.com/moreinfo>here!</a>"
即
{link}{url}{text}{link} --> <a href=url>text</a>
任何人有一个很好的建议?我也可以改变输入字符串的格式。
试使用一些模板引擎,这里有几个:http://stackoverflow.co m/a/340243/351383 –