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;
}
}
查看全文
相关阅读:
pandas DataFrame
pandas Series
numpy nan和inf
Filder配置及使用教程
Vmware Ubuntu18.04更换清华源
numpy 其它常用方法
numpy 数组的拼接
numpy 数值的修改
numpy 索引和切片
class 绑定的数据对象不必内联定义在模板里
原文地址:https://www.cnblogs.com/Random/p/400712.html
最新文章
jQuery的表单选择器
jQuery的节点操作
jQuery的基础dom和css操作
jQuery的过滤器总结
jQuery的选择器的总结
Dom总结
JavaScript总结1
我的家庭
html标签小结
python scrapy
热门文章
PHP 中最全的设计模式(23种)
php 门面模式
源码解读 Laravel PHP artisan config:cache
gitlab覆盖率
laravel架构
Laravel 5使用faker Model Factory生成网站模拟演示数据
laravel service provider
shadow一键安装
Linux常用网络工具:Http压力测试之ab
DataFrame数据合并
Copyright © 2011-2022 走看看