代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Java
】
搜索文本内所有的email地址并打印出来
作者:
DDT
/ 发布于
2012/1/29
/
626
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern;</div> <div>public class SearchAddress {//TODO 创建查找地址类 /** * @author liuxuewei */ public static void main(String []args) throws IOException{ try { BufferedReader in=new BufferedReader(new FileReader("F://Java编程//text1.txt")); Pattern regex=Pattern.compile("(<a href="file://\\w[-.\\w]*\\@[-a-z0-9]+(\\.[-a-z0-9]+)*\\.(com|edu|info">\\w[-.\\w]*\\@[-a-z0-9]+(\\.[-a-z0-9]+)*\\.(com|edu|info</a>))", Pattern.CASE_INSENSITIVE|Pattern.MULTILINE); String tempstr=new String(); String str=new String(); String find=null; while((tempstr=in.readLine())!=null){ str=str+tempstr+"\n"; } Matcher mat=regex.matcher(str); while(mat.find()){//TODO 测试regex find=mat.group(1); System.out.println("Find:"+find); System.out.println("匹配的正则式:"+regex.pattern());//输出匹配的正则表达式 } if(find==null) System.out.print("Can't Find"); } catch (FileNotFoundException e) { e.printStackTrace(); } } } <div></div> <div></div> <div>下面为搜索的文本主要片段: Subject: E-mail comes from America Bob; Date: 19,Feb,2012; To: <a href="mailto:liu.xuewei@hotmail.com">liu.xuewei@hotmail.com</a> From: <a href="mailto:Bob_Edission@gmail.com">Bob_Edission@gmail.com</a>; Serlet: <a href="http://www.Yahoo.com">http://www.Yahoo.com</a>; Store: <a href="http://www.taobao.com/QuintStore/1315.html">http://www.taobao.com/QuintStore/1315.html</a> Hello, Nice to write to you a letter again and Happy New Year! Microsoft Windows Media recently released upgrades to our Software Development Kit (SDK) family. The Windows Media Player 10 SDK enables you to synchronize content with portable devices and integrate premium services with Windows Media Player. The Windows Media Format 9.5 SDK provides two new codecs and extended digital rights management (DRM) support to protect your content. The Windows Media Rights Manager 10 SDK supports new DRM rights. Finally, the Windows XP Media Center Edition SDK has been significantly enhanced to enable you to extend Media Center capabilities. The Microsoft SharePoint Products and Technologies 2003 SDK provides conceptual overviews, programming tasks, samples, and references for developing solutions using Microsoft Windows? SharePoint Services and Microsoft Office SharePoint Portal Server 2003. Find new SharePoint Portal Server information to get you started, to extend search, and to integrate SharePoint Portal Server with other enterprise applications April 2008 Yours Bob</div>
试试其它关键字
email地址
同语言下
.
List 切割成几份 工具类
.
一行一行读取txt的内容
.
Java PDF转换成图片并输出给前台展示
.
java 多线程框架
.
double类型如果小数点后为零则显示整数否则保留两位小
.
将图片转换为Base64字符串公共类抽取
.
sqlParser 处理SQL(增删改查) 替换schema 用于多租户
.
JAVA 月份中的第几周处理 1-7属于第一周 依次类推 29-
.
java计算两个经纬度之间的距离
.
输入时间参数计算年龄
可能有用的
.
实现测量程序运行时间及cpu使用时间
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
DDT
贡献的其它代码
(
160
)
.
Oracle统计表的数据行和数据块信息
.
html标签闭合检测与修复
.
Powershell日期计算
.
Powershell的Base64编解码
.
Powershell并行循环
.
Powershell目录中搜索文本
.
Powershell枚举远程机器上的本地权限组
.
VBScript解析csv文件
.
快速排序之Powershell
.
批处理输出格式化时间字符串
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3