用ASP如何验证接收的内容是在数字,26个英文字母,下划线范围内,并且区分大小写.

lingzi 2001-12-11 10:05:29
用ASP如何验证接收的内容是在数字,26个英文字母,下划线范围内,并且区分大小写.
...全文
220 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lingzi 2001-12-12
  • 打赏
  • 举报
回复
我给你加分了,小虎
puppet 2001-12-12
  • 打赏
  • 举报
回复
用vbscript可以这样写
<%
Function isemail(strng)
isemail = false
Dim regEx, Match
Set regEx = New RegExp
regEx.Pattern = "[A-Za-z0-9_]+"
regEx.IgnoreCase = True
Set Match = regEx.Execute(strng)
if match.count then isemail= true
End Function
%>
模式你可以自己改
puppet 2001-12-12
  • 打赏
  • 举报
回复
1 、判断数字的正确性
<script language="javascript" runat="server">
function isNumeric(strNumber) { '数字
return (strNumber.search(/^(-¦\+)?\d+(\.\d+)?$/) != -1);
}
function isUnsignedNumeric(strNumber) { '非负数字
return (strNumber.search(/^\d+(\.\d+)?$/) != -1);
}
function isInteger(strInteger) { '整数
return (strInteger.search(/^(-¦\+)?\d+$/) != -1);
}
function isUnsignedInteger(strInteger) { '非负整数
return (strInteger.search(/^\d+$/) != -1);
}
</script>

2、判断Email格式的正确性
<%
Function isemail(strng)
isemail = false
Dim regEx, Match
Set regEx = New RegExp
regEx.Pattern = "^\w+((-\w+)¦(\.\w+))*\@[A-Za-z0-9]+((\.¦-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$"
regEx.IgnoreCase = True
Set Match = regEx.Execute(strng)
if match.count then isemail= true
End Function
%>

3.UBB论坛
Function ReplaceTest(patrn,str,replStr)
Dim regEx, str1 " 建立变量。
str1=trim(str)
Set regEx = New RegExp " 建立正则表达式。
regEx.Pattern = patrn " 设置模式。
regEx.IgnoreCase = true " 设置是否区分大小写。
ReplaceTest = regEx.Replace(str1, replStr) " 作替换。
set regEx=nothing ‘销毁正则表达式对象
End Function

ReplaceTest("(\[img])(\S+)(\[/img])",temp,"<img src=""$2"">")

lingzi 2001-12-12
  • 打赏
  • 举报
回复
能具体说一下语句吗
lingzi 2001-12-11
  • 打赏
  • 举报
回复
具体些好吗?
puppet 2001-12-11
  • 打赏
  • 举报
回复
用正则表达式,search一下

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧