日期:2014-05-17  浏览次数:21025 次

如何检测邮箱中带点"."的个数
如何检测邮箱中带点"."的个数

------解决方案--------------------
JScript code
alert("a.2.4.5@11.com".match(/\./g).length)

------解决方案--------------------
Function getEmailDotLen(s)
dim l=0,sp=".",aryReturn 
if s!="" then

If InStr(s,sp)=0 then '去除开头的.
s=Mid(s,1)
end if
aryReturn = Split(s,sp)'用点分割字符串得到数组
getEmailDotLen=UBound(aryReturn)+1
end if
getEmailDotLen=l
End Function

Response.Write getEmailDotLen("a.2.4.5@11.com")
------解决方案--------------------
VBScript code
dim re, email, matches
email= "a.b.c.s@163.com."
Set re=new RegExp
re.Global=true
re.MultiLine=true
re.pattern= "\."
set matches = re.Execute(email)
response.write(matches.count)

------解决方案--------------------
s="abc.abc.abc"
i = len(s)-len(replace(s,".",""))