时间:2016-02-15 21:50 来源: 我爱IT技术网 作者:佚名
欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【.NET读取所有目录下文件正则匹配文本电子邮件】,下面是详细的讲解!
.NET读取所有目录下文件正则匹配文本电子邮件
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
namespace Test
{
class FiEmail
{
public static void Main(string[] args) {
Console.WriteLine("请输入内容路径:");
string[] fs=Directory.GetFiles(args[0]);
if(fs!=null){
string jobsPattern=@"([\w-]+(\.\w+)*@([\w-]+\.)+\w{2,3})";
Regex rx=new Regex(jobsPattern,RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline );
foreach(string s in fs){
Console.WriteLine("匹配");
string asR=File.ReadAllText(s);
MatchCollection matches=rx.Matches(asR);
if(matches!=null && matches.Count>0) {
string argsP="";
for(int loopI=0;loopI<matches.Count;loopI++){
argsP+=(matches[loopI].Groups[0].Value)+Environment.NewLine ;
}
W(argsP.Trim(new char[]{'\n'}));
}
Console.WriteLine(s);
}
}
Console.ReadLine();
}
public static void W(string ids){
string paths=System.IO.Path.Combine(@"C:\Documents and Settings\Administrator\桌面\GC\","edel.txt");
using (System.IO.StreamWriter sr=new System.IO.StreamWriter(paths,true)){
sr.WriteLine(ids);
}
}
}
}
关于.NET读取所有目录下文件正则匹配文本电子邮件的用户互动如下:
相关问题:
答: >>详细
相关问题:
答: >>详细
相关问题:
答: >>详细
- 【asp】asp.net url重写浅谈-net-url重写
- 【创建】ASP.NET Web API教程 创建域模型的方法详
- 【页面打印】关于ASP.NET页面打印技术的常用方法
- 【MVC5】MVC 5 第一章 创建MVC 5 web应用程序-net
- 【服务器】asp.net页面状态管理cookie和服务器状
- 如何取消.net后台线程的执行
- 【asp】asp.net 分页链接方法-net-分页链接
- 【采集】asp.net采集网页图片的具体方法-网页-图
- 【ajax】asp.net下ajax.ajaxMethod使用方法-ajaxM
- 【WeakReference】WeakReference(弱引用)让GC需要
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
