开发者

How to parse Link, HashCode and ScreenName in Twitter Feeds using C#

I am using the following code to parse the string in javascript. And this is working fine. Now I wants the same thing in C#. I want to parse string using C#. How can I do it.

(FeedText).parseURL().parseUsername().parseHashtag()

String.prototype.parseUR开发者_如何学CL = function () {
    return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/g, function (url) {
        return url.link(url);
    });
};

String.prototype.parseUsername = function () {
    return this.replace(/[@]+[A-Za-z0-9-_]+/g, function (u) {
        var username = u.replace("@", "")
        return u.link("http://twitter.com/" + username);
    });
};

String.prototype.parseHashtag = function () {
    return this.replace(/[#]+[A-Za-z0-9-_]+/g, function (t) {
        var tag = t.replace("#", "%23")
        return t.link("http://search.twitter.com/search?q=" + tag);
    });
};


You should try and do it yourself first. Here's the starting point: http://dev.twitter.com/pages/open_source#csharp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜