2013-06-27 84 views

回答

-1

這裏是解決方案:

function replaceAtMentionsWithLinks(text) { 
       var exp = /@([a-z\d_]+)/ig; 
       return text.replace(exp, "<a href='http://twitter.com/$1' 
        <http://twitter.com/%241%27> @$1</a>"); 
       } 
     function replaceURLWithHTMLLinks(text) { 
       var exp = /(\b(www\.|http\:\/\/)\S+\b)/ig; 
       return text.replace(exp,"<a href='$1'>$1</a>"); 
       } 
     function replacehashtags(text) { 
       var exp = /\#(\w+)/ig; 
       return text.replace(exp, "<a target='_blank' 
       href='https://twitter.com/search?q=%23$1&src=hash'>#$1</a>"); 
       }