惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
爱范儿
爱范儿
Attack and Defense Labs
Attack and Defense Labs
量子位
The GitHub Blog
The GitHub Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Scott Helme
Scott Helme
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 叶小钗
C
Cybersecurity and Infrastructure Security Agency CISA
S
Securelist
S
Schneier on Security
C
Cisco Blogs
B
Blog RSS Feed
Cisco Talos Blog
Cisco Talos Blog
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
Y
Y Combinator Blog
Latest news
Latest news
T
Tailwind CSS Blog
Jina AI
Jina AI
宝玉的分享
宝玉的分享
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
Lohrmann on Cybersecurity
The Cloudflare Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Security Blog
Microsoft Security Blog
H
Help Net Security
P
Palo Alto Networks Blog
V
V2EX
博客园_首页
D
Docker
T
Threat Research - Cisco Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Vulnerabilities – Threatpost
月光博客
月光博客
D
DataBreaches.Net
Stack Overflow Blog
Stack Overflow Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Know Your Adversary
Know Your Adversary
L
LangChain Blog
The Hacker News
The Hacker News
K
Kaspersky official blog
The Register - Security
The Register - Security
NISL@THU
NISL@THU

博客园 - gotolovo

导出csv 导出excel logmanager des 加密 解密 - gotolovo c# 发送邮件 工作流学习过程-事务 工作流学习过程-状态机 蛋疼的viewstate 工作流学习过程-持久化服务 工作流学习过程-使用关联 工作流学习过程-本地服务之事件处理 工作流学习过程-本地服务之调用方法 工作流学习过程-验证活动 工作流学习过程-自定义活动 工作流学习过程-开篇 基本的几个排序算法 关于sql中时间的格式转换 数据行变列 请编程遍历页面上所有TextBox控件并给它赋值为空
正则学习电话匹配
gotolovo · 2011-09-24 · via 博客园 - gotolovo
private static void Replace(string html)
{
if (html.IndexOf(',') > 0)
{
html = html.Substring(0, html.IndexOf(','));
}

html = Regex.Replace(html, @"\s|[a-z]|[\u4e00-\u9fa5]", string.Empty, RegexOptions.IgnoreCase);
//html = Regex.Replace(html, @"[a-z]", string.Empty, RegexOptions.IgnoreCase);
//html = Regex.Replace(html, @"[\u4e00-\u9fa5]", string.Empty, RegexOptions.IgnoreCase);
// 长度不足的直接返回
if (html.Length < 7)
{
// return html;
}
html = Regex.Replace(html, @"[–-\*]", "-");
html = Regex.Replace(html, "[(.)]", string.Empty);
html = Regex.Replace(html, "--", "-");
//html = Regex.Replace(html, ".", "");
//html = Regex.Replace(html, "–", "-");

if (Regex.IsMatch(html, @"^400"))
{
html = Regex.Replace(html, "-", "");
if (html.Length > 10)//有分机号
{
html = html.Insert(10, "-");
}
html += "特殊电话";
}
else if (Regex.IsMatch(html, @"^1[35]\d{9}$"))//正常手机
{
html = html + "正常手机";
}
else if (Regex.IsMatch(html, @"^1[35]\d{9}"))//不正常手机
{
html = Regex.Match(html, @"^1[35]\d{9}").Value + "不正常手机";
}
else if (Regex.IsMatch(html, @"^0\d{2,3}-*\d{7,8}$"))//正常电话无分机号
{
html = Regex.Replace(html,"-",string.Empty) + "正常电话";
}
else if (Regex.IsMatch(html, @"^0\d{2,3}-*\d{7,8}-*\d+$"))//正常电话有分机号
{
html += "正常电话有分机号";
}
else if(Regex.IsMatch(html, @"^0\d{2,3}-*\d{4,6}-*\d{2,4}$"))//正常电话无分机号被字符分隔
{
html = Regex.Replace(html, "-", string.Empty) + "正常电话无分机号被字符分隔";
}
else if (Regex.IsMatch(html, @"^(0\d{2,3}-*\d{4,6}-*\d{2,4})(-\d+$)"))//正常电话有分机号被字符分隔
{
Match match = Regex.Match(html, @"^(0\d{2,3}-*\d{4,6}-*\d{2,4})(-\d+$)");//正常电话有分机号被字符分隔
html = match.Groups[1].Value.Replace("-", string.Empty) +match.Groups[2].Value +"正常电话有分机号被字符分隔";
}
else
{
html = string.Empty;
}
Console.WriteLine(html);
//return html;
}


编辑器加载中...