【发布时间】:2011-10-21 21:15:32
【问题描述】:
我最近从 TweetSharp 切换到了 LinqToTwitter,而我缺少的一件事是将推文检索为 HTML 的方法。
TweetSharp 有一个名为.TextAsHtml() 的方法,它自动链接提及、哈希标签和超链接。
有人知道LinqtoTwitter 中是否存在这样的功能吗?任何有关 TweetSharp 如何实现这一点的见解都将非常有用。
更新:
看起来 TweetSharp 使用正则表达式来匹配 URL、提及和哈希标签。这是一个示例:
private static readonly Regex _parseUrls = new Regex("\\b(([\\w-]+://?|www[.])[^\\s()<>]+(?:\\([\\w\\d]+\\)|([^\\p{P}\\s]|/)))", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex _parseMentions = new Regex("(^|\\W)@([A-Za-z0-9_]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex _parseHashtags = new Regex("[#]+[A-Za-z0-9-_]+", RegexOptions.IgnoreCase | RegexOptions.Compiled);
【问题讨论】:
-
你不能在 _parseHashtags 上使用正则表达式替换方法吗?
标签: c# asp.net twitter tweetsharp