A few simple regular

Source: Internet
Author: User
Regular | regular <%
Rem # Simple regular checks to see if illegal characters are included
Rem # str string to be detected
Rem # Badwordlist filtered strings, must be | Apart
function Ishavebadword (str, badwordlist)
Dim Strpattern
Strpattern = badwordlist & "+"
Dim Oregex, Omatch
Set Oregex = New RegExp
Oregex.ignorecase = True ' is case-insensitive
Oregex.global = True
Oregex.pattern = Strpattern
Set omatch = Oregex.execute (str)
If Omatch.count Then
Ishavebadword = True
Else
Ishavebadword = False
End If
End Function

Rem # Simple regular replaces illegal characters with a * instead
Rem # str string to be detected
Rem # Badwordlist filtered strings, must be | Apart
function Replacebadword (str, badwordlist)
Dim Strpattern
Strpattern = badwordlist & "+"
Dim Oregex, Omatch
Set Oregex = New RegExp
Oregex.ignorecase = True ' is case-insensitive
Oregex.global = True
Oregex.pattern = Strpattern
Replacebadword = Oregex.replace (str, "*")
Set Oregex = Nothing
End Function

Response. Write ("ASP Xiao Month Mark Xiaoyuehen" & Ishavebadword ("ASP Xiao Month mark Xiaoyuehen", "xiaoyuehen| Xiao Month mark") & "<br>")
Response. Write ("ASP Xiao Month Mark Xiaoyuehen" & Replacebadword ("ASP Xiao Month mark Xiaoyuehen", "xiaoyuehen| Xiao Month mark") & "<br>")

Rem # Detects whether a sequence of digits is separated. Multiple-selection commit detection available for forms
Rem # str string to be detected
function Matchnumlist (str)
Dim Strpattern
Strpattern = "^[0-9]{1,} (, [0-9]+) {0,}$"
Dim Oregex, Omatch
Set Oregex = New RegExp
Oregex.ignorecase = True ' is case-insensitive
Oregex.global = True
Oregex.pattern = Strpattern
Set omatch = Oregex.execute (str)
If Omatch.count Then
Matchnumlist = True
Else
Matchnumlist = False
End If
End Function
Response. Write ("6,1245,2122,456" & Matchnumlist ("6,1245,2122,456") & "<br>")
Response. Write ("6,1a45,2122,456" & Matchnumlist ("6,1a45,2122,456") & "<br>")
Response. Write (", 6,1245,2122,456" & Matchnumlist (", 6,1245,2122,456") & "<br>")
Response. Write ("6,1245,2122,456," & Matchnumlist ("6,1245,2122,456,") & "<br>")
%>



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.