直播中
<%
'調(diào)用這個(gè)函數(shù)來(lái)顯示成超聯(lián)結(jié)
Response.Write to_html(s_message)
%>
<%
Function to_html(s_string)
to_html = Replace(s_string, """", """)
to_html = Replace(to_html, "<", "<")
to_html = Replace(to_html, ">", ">")
to_html = Replace(to_html, vbcrlf, "<br>")
to_html = Replace(to_html, "/<", "<")
to_html = Replace(to_html, "/>", ">")
to_html = edit_hrefs(to_html)
End Function
%>
<script language="javascript1.2" runat=server>
function edit_hrefs(s_html){
// 一個(gè)使用正則表達(dá)式的典范
// 轉(zhuǎn)換文本中所有的超聯(lián)結(jié)和電子郵件格式
s_str = new String(s_html);
s_str = s_str.replace(/\bhttp\:\/\/www(\.[\w+\.\:\/\_]+)/gi,
"http\:\/\/¬¤¸$1");
s_str = s_str.replace(/\b(http\:\/\/\w+\.[\w+\.\:\/\_]+)/gi,
"<a href=\"$1\">$1<\/a>");
s_str = s_str.replace(/\b(www\.[\w+\.\:\/\_]+)/gi,
"<a href=\"http://$1\">$1</a>");
s_str = s_str.replace(/\bhttp\:\/\/¬¤¸(\.[\w+\.\:\/\_]+)/gi,
"<a href=\"http\:\/\/www$1\">http\:\/\/www$1</a>");
s_str = s_str.replace(/\b(\w+@[\w+\.?]*)/gi,
"<a href=\"mailto\:$1\">$1</a>");
return s_str;
}
</script>