Article View: cn.comp.os.linux
Article #591Re: 问一句正则表达式该怎么写
From: Luo Yong
Date: Sun, 13 Sep 2009 19:12
Date: Sun, 13 Sep 2009 19:12
64 lines
2719 bytes
2719 bytes
Java�棺
=====>>>
package testjava;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.regex.Pattern;
/**
*
* @author yong
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// Text file contains the mail addresses.
File inputFile = new File("/home/yong/text.txt");
try {
FileInputStream input = new FileInputStream(inputFile);
InputStreamReader inputReader = new InputStreamReader(input);
BufferedReader reader = new BufferedReader(inputReader);
String line = reader.readLine();
while(line != null) {
line = line.trim();
// Print the line if matched.
if (!Pattern.matches("^.*?@gmail.com.*?$", line)) {
System.out.println(line);
}
line = reader.readLine();
}
}catch(Exception e) {
e.printStackTrace(System.err);
}
}
}
=====<<<
"Moses" <moses.mason@gmail.com> writes:
> ���ÿ��һ��, ������һЩ�ʼ���ַ
> aaa@gmail.com
> bbb@gmail.com
> ...
> ...
> ccc@163.com
> ddd@yahoo.com
> eee@hotmail.com
>
> �����뽫���в���ij�ֶ� (����� Gmail ��) �����滻Ϊ����, ������ʽӦ����ôд?
> ������ [^gmail.com]$ ����ֻ��ƥ�䲿��, ���� @163.com ��β�ľ������, ��֪��ʲôԭ��
>
> лл
Technical Details
Message-ID:
<87r5uaodzk.fsf@hotmail.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsgate.cuhk.edu.hk!www.shinco.com!news.cnusenet.org!not-for-mailReferences:
<h8fug1$no0$1@www.shinco.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 3473bcdd2c,da30bf8c4d964ec9 X-Google-Attributes: gid3473bcdd2c,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,GB Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsgate.cuhk.edu.hk!www.shinco.com!news.cnusenet.org!not-for-mail From: Luo Yong <luo.yong.name@hotmail.com> Newsgroups: cn.comp.os.linux,cn.fan Subject: Re: 问一句正则表达式该怎么写 Date: Sun, 13 Sep 2009 12:12:47 -0700 Organization: Guohai.org Lines: 64 Message-ID: <87r5uaodzk.fsf@hotmail.com> References: <h8fug1$no0$1@www.shinco.com> NNTP-Posting-Host: 123.188.10.192 Mime-Version: 1.0 Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 8bit X-Trace: www.shinco.com 1252817418 11192 123.188.10.192 (13 Sep 2009 04:50:18 GMT) X-Complaints-To: news@www.shinco.com NNTP-Posting-Date: Sun, 13 Sep 2009 04:50:18 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) Cancel-Lock: sha1:uqAQUkll+GwqE+5ORbTDLPuNU0Q=