/ Published in: ActionScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public static const homeLink:String = "http://twitter.com"; public static const timelineURIPattern:String = homeLink + "/statuses/user_timeline/{userName}.xml?count={count}&page={page}"; public static const userHomeURIPattern:String = homeLink + "/{userName}"; public static const linkPattern:RegExp = /https?:\/\/([-\w\.]+)+(\/([\w\/_\.]*(\?\S+)?(#\S+)?)?)?/g; public static const linkReplace:String = "<a href='$&' target='_blank'>$&</a>"; public static const userPattern:RegExp = /@(\w+)/g; public static const userReplace:String = "@<a href='"+ homeLink + "/$1' target='_blank'>$1</a>"; public static const tagLink:String = "http://search.twitter.com/search?q=%23"; public static const tagPattern:RegExp = /(\s+)#(\w+)/g; public static const tagReplace:String = "$1<a href='"+tagLink+"$2' target='_blank'>#$2</a>"; public static const tagPattern2:RegExp = /^#(\w+)/; public static const tagReplace2:String = "<a href='"+tagLink+"$1' target='_blank'>#$1</a>"; public static function replaceAll(text:String):String { text = text.replace(linkPattern,linkReplace); text = text.replace(userPattern,userReplace); text = text.replace(tagPattern,tagReplace); text = text.replace(tagPattern2,tagReplace2); return text; }