Asp,vbs is turning in the article paragraph backward plus URL and other content _ Application skills

Source: Internet
Author: User
<script language = "vbs" >
' Function name: regexptest
' Parameters: strng--' The string to be processed; patrn--to | A variety of trailing signs such as:<br/>|</p>|<br>; patrn2--"to be replaced by a string, also to | separate
Open
' Author: Liu YONGFA (yongfa365) ' Blog
' function: Add the contents of patrn2 in the STRNG string followed by the patrn end character

Function regexptest (strng, PATRN, patrn2)
Dim regEx, Match, matches ' Set variable.
Set regEx =new RegExp ' establishes regular expressions.
Regex.ignorecase =true ' Sets whether to differentiate character case.
Regex.global =true ' Sets global availability.
PATRN = Split (patrn, "|")
ForEach p in Patrn
Regex.pattern = P ' Set mode.
Strng = Regex.Replace (strng, "| |") & Chr (Ten) & P)
Next

Strng = Split (strng, "| |")
ForEach E in Strng
s = s + E + arrart (patrn2)
Next
Regexptest = S
Endfunction

Function Arrart (PATRN2)
Arrarti = Split (patrn2, "|")
Randomize
Arrart = Arrarti (CInt (UBound (arrarti) * Rnd))
Endfunction


STRNG = "111<br/>222</p>333<br/>444</p>555<br>666</p>111"
Source = strng
PATRN = "<br/>|</p>|<br>"
patrn2 = "www.xiaoshuo8.net|http://www.jb51.net/blog|hi.baidu.com/"
Words = Regexptest (strng, PATRN, patrn2)
MsgBox (words)

</script>

<script>
Document. Write "<fieldset><legend> Original string </legend>" + Source + "</fieldset><br>"
Document. Write "<fieldset><legend> after conversion string </legend>" + words + "</fieldset><br>"
</script>
Related Article

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.