Asp判断字符串中是否包含连续的重复字符
作者:admin 日期:2012-06-14
不允许字符串中连续重复超过2次,可以在发布信息网站禁止标题中发布某些无意义的重复字符!
ASP/Visual Basic代码
- function checkrepeat(txt)
- checkrepeat=false
- initialtxt=""
- num=1
- for i=1 to len(txt)
- character=mid(txt,i,1)
- if character=initialtxt then
- num=num+1
- else
- num=1
- end if
- initialtxt=character
- if num>2 then
- checkrepeat=true
- end if
- next
- end function
调用方法:
ASP/Visual Basic代码
- text="www.tianzhigang.com"
- if checkrepeat(text)=true then
- response.Write("有重复超过2个的字符!")
- else
- response.Write("无重复超过2个的字符!")
- end if
原创代码,转载请注明出处!http://www.tianzhigang.com
评论: 0 | 引用: 0 | 查看次数: 3466
发表评论
广告位