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

推荐订阅源

量子位
T
The Blog of Author Tim Ferriss
U
Unit 42
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
Vercel News
Vercel News
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
D
DataBreaches.Net
The GitHub Blog
The GitHub Blog
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
Blog — PlanetScale
Blog — PlanetScale
I
InfoQ
Y
Y Combinator Blog
F
Full Disclosure
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
G
Google Developers Blog
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
S
SegmentFault 最新的问题
腾讯CDC
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Visual Studio Blog
Apple Machine Learning Research
Apple Machine Learning Research
人人都是产品经理
人人都是产品经理
Recent Commits to openclaw:main
Recent Commits to openclaw:main
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Azure Blog
Microsoft Azure Blog
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
F
Fortinet All Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
T
Threatpost
GbyAI
GbyAI
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
L
LangChain Blog
T
Tenable Blog
C
Cisco Blogs
T
Threat Research - Cisco Blogs
Google Online Security Blog
Google Online Security Blog

博客园 - 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;
}


编辑器加载中...