HTML-Aware Markup replacement connection _ regular expression

Source: Internet
Author: User

Copy Code code as follows:

<%
Function Senfe_ubbcode (scontent)
Dim Tempreg
Set Tempreg = New RegExp
With Tempreg
. IgnoreCase = True
. Global = True
' Automatically identify URLs
If InStr (Lcase (scontent), "http://") >0 Then
. Pattern = "(^|[ ^<= ""]) (http: (\/\/|\\\\) ([\w\/\\\+\-~ ' @:%]) +\.) + ([\w\/\\\.\=\?\+\-~ ' @\ ':!%#]| (&) (|&) +) "
Scontent =. Replace (Scontent, "$1<a href=" "$" "target=" "_blank" ">$2</a>")
End If
' Automatic identification of Web sites at the beginning of www
If InStr (Lcase (scontent), "www.") >0 or InStr (Lcase (scontent), "BBS.") >0 Then
. Pattern = "(^|[ ^\/\\\w\=]) ((Www|bbs) \. ( \w) +\. ([\w\/\\\.\=\?\+\-~ ' @\ '!%#]| (&)) +)"
Scontent =. Replace (Scontent, "$1<a href=" "http://$2" "target=" "_blank" ">$2</a>")
End If
End With
Set Tempreg = Nothing
Senfe_ubbcode = Scontent
End Function
%>



<textarea id="runcode53643"><script language= "VBScript" > Function senfe_ubbcode (scontent) Dim tempreg Set tempreg = New RegExp with Temp Reg. IgnoreCase = True. Global = True ' automatically recognizes URL If InStr (Lcase (scontent), "http://") >0 Then. Pattern = "(^|[ ^<= ""]) (http: (\/\/|\\\\) ([\w\/\\\+\-~ ' @:%]) +\.) + ([\w\/\\\.\=\?\+\-~ ' @\ ':!%#]| (&) |&) +) "scontent =. Replace (scontent, "$1$2") End If ' automatically identifies the URL at the beginning of www, if INSTR (Lcase (scontent), "www.") >0 or InStr (Lcase (scontent), "BBS.") >0 Then. Pattern = "(^|[ ^\/\\\w\=]) ((Www|bbs) \. ( \w) +\. ([\w\/\\\.\=\?\+\-~ ' @\ '!%#]| (&)) +) "Scontent =. Replace (scontent, "$1$2") end If End with Set tempreg = no Senfe_ubbcode = Scontent End Function </script> <textarea name= "Scode" cols= "rows=" "></textarea> <input type=" button "value=" Replace "onclick=" Vbscript:document.getElementById (' Scode '). Value=senfe_ubbcode (document.getElementById (' Scode '). Value) "/> </textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.