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;
}
}
查看全文
相关阅读:
1462. 课程安排 IV
最全的CSS浏览器兼容问题【FF与IE】
this&super两个关键字的意义和用法
Javascript this 的一些总结
JS-封装类或对象的最佳方案
背景色透明,里面内容(图片、文字)不透明
css3 前端开发
html5游戏之Box2d物理引擎集成
Box2d引擎之元素
西天取经第一步——制作自己的HTML5游戏
原文地址:https://www.cnblogs.com/Random/p/400712.html
最新文章
ATM-java
POJ 1151 Atlantis(线段树-扫描线,矩形面积并)
POJ 2528 Mayor's posters (线段树)
Codeforce 370J Bottles(动态规划-01背包)
POJ 3180-The Cow Prom (图论-有向图强联通tarjan算法)
POJ 3352-Road Construction (图论-双边联通分支算法)
POJ 1236-Network of Schools (图论-有向图强联通tarjan)
Light OJ 1026
Hdu OJ 5113 Black And White (2014ACM/ICPC亚洲区北京站) (搜索)
Hdu OJ 5115 Dire Wolf (2014ACM/ICPC亚洲区北京站) (动态规划-区间dp)
热门文章
Hdu OJ 5884-Sort (2016 ACM/ICPC Asia Regional Qingdao Online)(二分+优化哈夫曼)
48. 旋转图像
714. 买卖股票的最佳时机含手续费
剑指 Offer 59
376. 摆动序列
数据结构期末复习题集
数据结构与算法期末复习题
797. 所有可能的路径
1557. 可以到达所有点的最少点数目
1267. 统计参与通信的服务器
Copyright © 2011-2022 走看看