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;
}
}
查看全文
相关阅读:
Kubernetes日志的6个最佳实践
如何选出适合自己的管理Helm Chart的最佳方式?
授权权限服务设计解析
微服务中如何设计一个权限授权服务
微服务中的网关
ketchup服务治理
ketchup 消息队列rabbitmq使用
ketchup 注册中心consul使用
微服务框架 ketchup 介绍
微服务框架surging学习之路——序列化
原文地址:https://www.cnblogs.com/Random/p/400712.html
最新文章
Java 调用http接口(基于OkHttp的Http工具类方法示例)
Java Lambda表达式forEach无法跳出循环的解决思路
前端模块化之循环加载
深入理解React:diff 算法
深入理解React:事件机制原理
深入理解React:懒加载(lazy)实现原理
深入理解JS:var、let、const的异同
深入理解JS:执行上下文中的this(二)
深入理解JS:执行上下文中的this(一)
深入理解JS中的对象(三):class 的工作原理
热门文章
深入理解JS中的对象(二):new 的工作原理
深入理解JS中的对象(一):原型、原型链和构造函数
误删节点或集群怎么办?这里有一颗后悔药
使用Rancher在K8S上部署高性能PHP应用程序
一文了解HAProxy主要特性
在采用K8S之前您必须了解的5件事情
6大服务网格工具比较
使用Kubeflow构建机器学习流水线
超详细实战教程丨多场景解析如何迁移Rancher Server
简单5步,轻松debug K8S服务!
Copyright © 2011-2022 走看看