注册 登录
编程论坛 ASP技术论坛

怎样判断生成的为16位大写字母?

dhdhzzw 发布于 2008-05-20 11:57, 968 次点击
我生成一个授权码,,想判断若不为16位大写字母,则不写进数据库,但16位大写字母我不会判断,,请指点。。。。。
8 回复
#2
永夜的极光2008-05-20 12:36
啥叫"16位大写字母",就是16个大写字母吗?
#3
multiple19022008-05-20 12:39
很简单,判断每位(Mid(str,start,1))的ASCII码值大于等于A (asc("A")) 小于等于Z
#4
dhdhzzw2008-05-20 13:45
[bo]以下是引用 [un]multiple1902[/un] 在 2008-5-20 12:39 的发言:[/bo]

很简单,判断每位(Mid(str,start,1))的ASCII码值大于等于A (asc("A")) 小于等于Z

循环判断?好的我试试,谢谢
#5
dhdhzzw2008-05-22 10:16
这段代码最后几句我不明白,请指点。。。
function   isnaw(str)
for   i=1   to  len(str)
str1=mid(str,i,1)
if    (Asc(str1)> Asc( "A ") and   Asc(str1) <Asc( "Z ")) and len(str)=16  then   isw=1 ---判断是否为大写16位字母
next
if    isw=1   then   
isnaw=true
else
isnaw=false
end   if
end   function
    [bo]pw= "123qq "
if   isnaw(pw)   then   =------这里是判断什么?是不是该这样写[color=Blue]isnaw(pw)    if isnaw=true then  .
下面。。。。。
response.write   "y "
else
response.write   "n "
end   if [/bo][/color]

[[it] 本帖最后由 dhdhzzw 于 2008-5-22 10:18 编辑 [/it]]
#6
google2008-05-22 11:09
Function IsDaxie(patrn, str)
if len(str)<>16 then
IsDaxie=false
else
  Dim regEx, retVal            ' 建立变量。
  Set regEx = New RegExp         ' 建立正则表达式。
  regEx.Pattern = patrn         ' 设置模式。
  regEx.IgnoreCase = FALSE         ' 设置是否区分大小写。
  retVal = regEx.Test(str)         ' 执行搜索测试。
  If retVal Then
    IsDaxie= true
  Else
    IsDaxie = false
  End If
end if
End Function
response.write( IsDaxie("^[A-Z]+$","AAAAAAAAAAAAAAAa"))
#7
google2008-05-22 11:11
<%


Function IsDaxie(str)
if len(str)<>16 then
IsDaxie=false
else
  Dim regEx, retVal            ' 建立变量。
  Set regEx = New RegExp         ' 建立正则表达式。
  regEx.Pattern = "^[A-Z]+$"         ' 设置模式。
  regEx.IgnoreCase = FALSE         ' 设置是否区分大小写。
  retVal = regEx.Test(str)         ' 执行搜索测试。
  If retVal Then
    IsDaxie= true
  Else
    IsDaxie = false
  End If
end if
End Function
response.write( IsDaxie(你的字符串))
%>
#8
dhdhzzw2008-05-22 13:31
不太会用正则,,但学习了,谢谢
#9
hxfly2008-05-22 13:49
正则就是一种死方法,就和创建数据库连接一样。
关键就是他的匹配表达式。
但是大部分匹配表达式网上全有,呵呵,遇到不会的去网上搜下就可以了。
1