<iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-1294368471619564&amp;dt=1150677702359&amp;lmt=1150677702&amp;format=250x250_as&amp;output=html&amp;url=http%3A%2F%2Fwww.manbu.net%2FLib%2FClass1%2FSub11%2F1%2F8.asp&amp;color_bg=ECF8FF&amp;color_text=6F6F6F&amp;color_link=0000CC&amp;color_url=008000&amp;color_border=B4D0DC&amp;ad_type=text&amp;ref=http%3A%2F%2Fwww.manbu.net%2FLib%2FClass1%2FSub11%2Findex.asp&amp;cc=100&amp;u_h=768&amp;u_w=1024&amp;u_ah=740&amp;u_aw=1024&amp;u_cd=32&amp;u_tz=480&amp;u_his=3" frameborder="0" width="250" scrolling="no" height="250" allowtransparency=""></iframe>#######################
# Author: Rain wave All rights reserved, duplicate say #
#qq:270499458 #
#######################
Recently some friends who have just learned regular expressions ask me how to use in ASP. Oh Although it is simple, write it, the basic knowledge of regular expressions I will not say. In fact, there are many such articles. :(
##### function Code ########
assumed to be myfunc.asp
<%
' Regular table expression validation function patrn-Regular expression strng-a string to be validated
Function regexptest (PATRN, STRNG)
Dim regEx, RetVal ' Set variable.
Set regEx = New RegExp ' establishes a regular expression.
Regex.pattern = Patrn ' Set mode.
Regex.ignorecase = False ' Sets whether case sensitive.
RetVal = regex.test (strng) ' performs a search test.
Regexptest = RetVal ' Returns the value, does not conform returns false, conforms to true
End Function
%>
##### Submit page Code ######
assumed to be mypage.asp
<form method= "POST" action= "check.asp" >
Please enter e-mail address: <input type=text name=email>
<br>
Please enter the phone number: <input type=text name=tel>
<input type=submit value= "OK" >
</form>
##### Validation Page ########
assumed to be check.asp
<!--#include file= "myfunc.asp"-->
<%
Tel=request.form ("tel")
Email=request.form ("email")
Dim founderr:founderr=false ' Create variable, correct or fail tag
' Everybody, by the way, I'm here to contribute a regular expression and verify the phone number and phone number!
If Regexptest ("(^[0-9]{3,4}\-[0-9]{3,8}$) | ( ^[0-9]{3,8}$) | (^\ ([0-9]{3,4}\) [0-9]{3,8}$) | (^0{0,1}13[0-9]{9}$) ", tel) =false Then
Founderr=true
regshow=regshow& "<li> The phone number you entered is not in the correct format"
End If
If Regexptest ("^[\w-]+" (\.[ \w-]+) *@[\w-]+ (\.[ \w-]+) +$ ", email) =false Then
Founderr=true
regshow=regshow& "<li> e-mail you entered is not in the correct format"
End If
If Founderr=false then regshow= "<li> the format you entered is correct."
%>
<br><br>
<%=regshow%>