【发布时间】:2010-09-07 03:40:57
【问题描述】:
我正在使用 Twitter API 并希望将所有 URL 转换为超链接。
您想出的最有效的方法是什么?
来自
string myString = "This is my tweet check it out http://tinyurl.com/blah";
到
This is my tweet check it out <a href="http://tinyurl.com/blah">http://tinyurl.com/>blah</a>
【问题讨论】:
-
对于这个应用程序,您应该寻找一个与 Twitter 本身解析 URL 的方式完全匹配的解决方案——正则表达式可能会起作用;只需确保使用与 Twitter 相同的条件来匹配 URL 的结尾(相对于点和右括号)。