zoukankan
html css js c++ java
今天写了个检测邮件格式的算法~~
public
class
Check
{
public
static
bool
CheckEmail(
string
EmailString)
{
bool
Result
=
false
;
if
(EmailString.Length
>=
3
)
{
bool
atString
=
false
;
bool
dotString
=
false
;
int
atPosition
=
0
,atCount
=
0
;
int
dotPosition
=
0
;
string
Postfix;
Postfix
=
EmailString.Substring(EmailString.Length
-
3
,
3
);
Result
=
PostfixCheck(Postfix);
for
(
int
i
=
0
;i
<
EmailString.Length;i
++
)
{
if
(EmailString.Substring(i,
1
)
==
"
@
"
)
{
atString
=
true
;
atCount
+=
1
;
atPosition
=
i;
}
if
(EmailString.Substring(i,
1
)
==
"
.
"
)
{
dotString
=
true
;
dotPosition
=
i;
}
}
if
(atString
&&
dotString
&&
atCount
==
1
&&
System.Math.Abs(atPosition
-
dotPosition)
>
1
&&
Result)
Result
=
true
;
else
Result
=
false
;
}
else
Result
=
false
;
return
Result;
}
private
static
bool
PostfixCheck(
string
PostfixString)
{
bool
PostfixResult
=
false
;
string
PostfixTableString
=
"
com|net|org|cn |jp |gov|edu|int|mil|biz|cc |tv |ac |au |de |fr |hk |tw |uk |us |
"
;
//
要添加的后缀
for
(
int
i
=
0
;i
<
PostfixTableString.Length;i
+=
4
)
{
if
(PostfixString.ToUpper()
==
PostfixTableString.Substring(i,
3
).Trim().ToUpper()
||
PostfixString.Substring(
1
,
2
).ToUpper()
==
PostfixTableString.Substring(i,
3
).Trim().ToUpper())
{
PostfixResult
=
true
;
break
;
}
}
return
PostfixResult;
}
}
查看全文
相关阅读:
关于一位程序员入门的面试经验
Outpro的博客测试
优先队列
linux (centos 6.2)在输入查询或者操作命令时提示-bash: fork: cannot allocate memory
win10下JDK环境变量
Mac OS如何安装IDEA
解决下载github代码慢的问题
vue 模板语法之指令
vue的基本介绍以及第一个程序
消息中间的几大应用场景
原文地址:https://www.cnblogs.com/Random/p/400712.html
最新文章
vscode 切换中英文界面
设置vscode缩进的空格数
mac如何截图
利用 tkinter 实现小工具
python模拟登录获取网站cookie
谷歌浏览器xpath获取网页按钮路径
pycharm安装第三方的包
vim常用快捷键总结一(光标移动命令)
css属性挖掘:object-fit
返回指定盒子的顶部
热门文章
限制输入框只能输入数字和小数点,并且小数点后只能输入两位小数
四步搭建直播系统服务器,实操演示找物直播小程序(家具直播案例)
爱奇艺|B站|优酷|腾讯视频高清无水印视频下载方法(软件工具教程)
关于vue全家桶
bug记录——POST请求变成OPTIONS
一些有用的网址,不定时更新哦
批量删除微博代码
实验楼Linux环境创建首个vue应用
hive语法
IOC
Copyright © 2011-2022 走看看