Some of the previously collected data---convert text to hyperlinks and email format code

Source: Internet
Author: User
Tags regular expression
If the user enters the HTTP://AAA.BBB.CCC
The following code converts his input into a HTTP://AAA.BBB.CCC
We look at the regular expression of how powerful, hehe.
<%
' Call this function to display as a super join
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) {
An example of using regular expressions
Convert all hyperlinks and e-mail formats in text
S_str = new String (s_html);
S_str = S_str.replace (/http://www (. [ w+.:/ _]+)/gi,
"Http://¬¤¸$1");
S_STR = S_str.replace (/(http://w+.[ w+.:/ _]+)/gi,
"<a href=" (">$1</a>");

S_STR = S_str.replace (/(www.[ w+.:/ _]+)/gi,
"<a href=" http://$1 ">$1</a>");

S_str = S_str.replace (/http://¬¤¸ (. [ w+.:/ _]+)/gi,
"<a href=" http://www$1 ">http://www$1</a>");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.