校验email的合法性

/******************************************************************************/ //函数名: gf_IsValidEmail //功能说明:校验email的合法性 //输入参数:1.as_email 待校验的email //输出参数:无 //返回值: 0_合法,1_不合法 //函数完成:woods //调用关系:本函数为公共外部函数,可被系统开发的任何地方调用 /******************************************************************************/ string ls_ValidChar,ls_checkletter Integer  i,j integer  li_pos1,li_pos2,li_posT

//设定email的合法字符串 ls_ValidChar="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.@" //判断email中是否存在唯一的'@' li_pos1=pos(as_email,'@') if li_pos1=0 then //不包含'@'  return 1 else  //判断是否包含多个'@'  if pos(as_email,'@',li_pos1 + 1)>0 then   return 1  end if end  if //判断email中是否存在唯一的'.' li_pos2=pos(as_email,'.') if li_pos2=0 then //不包含'.'  return 1 else  //判断是否包含多于2个'.'或两个'.'在一起  li_posT=pos(as_email,'.',li_pos2 + 1)  if li_posT>0 then   if li_posT=li_pos2 + 1 then //两个在一起    return 1   else  //是否多于2个    if pos(as_email,'.',li_posT + 1)>0 then     return 1    end if   end if  else   li_posT=li_pos2  end if end if //判断'@'位置是否合法,不再第一、最后 if left(as_email,1)='@' or right(as_email,1)='@' then  return 1 end if //判断'.'位置是否合法 if left(as_email,1)='.' or right(as_email,1)='.' then  return 1 end if //判断'.'是否在'@'出现,并且不是紧挨着 if li_pos2>li_pos1 + 1 and li_posT>li_pos1 + 1 then else  return 1 end if //判断email得每个字符是否在合法字符中 For i=1 To len(as_email)  ls_checkletter=mid(as_Email,i,1)  If pos(ls_ValidChar,ls_checkletter)=0 Then    return 1  End If Next

return 0

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值