Code for converting text to hyperlink and email format

Time:2022-5-2

If the user enters http://aaa.bbb.ccc
The following code will convert his input into http://aaa.bbb.ccc
Let’s see how powerful regular expressions are, ha ha.

<%
‘call this function to display as a hyperjoin
    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 hypertext and in e-mail links
    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([email protected][w+.?]*)/gi,
        “<a href=”mailto:$1″>$1</a>”);

   
    return s_str;
}
</script>

Recommended Today

JVM + GC parsing (premise knowledge concatenation)

Premise preparation JVM GC garbage collection JVM virtual machine monitoring, tuning and troubleshooting Tomcat and microservice optimization 1. Premise review 1.1. JVM memory structure 1.1.1、 JVM Architecture Overview The gray part in the figure isThread private, there is almost no garbage collectionOrange partThread sharing, the main place where garbage recycling occurs What is the class […]