(JAVA)Regular Expression测试
来源:互联网 发布:腾讯云域名dns未生效 编辑:程序博客网 时间:2024/05/01 14:06
前一段做毕业设计期间,由于想把程序做的好一点就学习了一下Regular Expression,然后就有了以下代码,做测试。
/** RETry.class
* Author: Jack
* Date: 2004-10
*/
import java.util.regex.*;
import java.io.*;
public class RETry {
public static void main(String[] args) {
Pattern p;
Matcher m;
BufferedReader in =
new BufferedReader(new InputStreamReader(System.in));
boolean done = false;
String line = new String();
System.out.println("Copyright @ 2004,Author Jack Lee,Version 1.0");
System.out.println("Welcom to use!");
System.out.print("Now Give me a Pattern:");
try {
line = in.readLine();
}
catch (IOException e){}
if (line.equals("quit")){
System.out.println("Bye!");
System.exit(0);
}
p = Pattern.compile(line);
while (!done) {
System.out.print("command>>");
try {
line = in.readLine();
}
catch(IOException e){
}
if (line.equals("quit")) {
done = true;
System.out.println("Bye!");
continue;
} // end of if ()
else if (line.equals("change")) {
System.out.print("Now change the Pattern:");
try {
line = in.readLine();
}
catch (IOException e){
}
if (line.equals("quit")) {
System.out.println("Bye!");
System.exit(0);
}
p = Pattern.compile(line);
continue;
} // end of else if ()
m = p.matcher(line);
if (m.matches()) {
System.out.println("Match!");
} // end of if ()
else {
System.out.println("Don't Match!");
} // end of else
} // end of while ()
} // end of main()
}///:~
附: j2sdk1.4.2,平台WinXP。还有毕设答辨时表现不太好,,还要努力啊!!!
- (JAVA)Regular Expression测试
- Java and Regular Expression
- Java and Regular Expression
- [java]Regular Expression Testor
- Java regular expression
- Java Regular Expression Tutorial
- Regular Expression Matching (Java)
- Java regular expression regex
- java regular expression
- Java Regular Expression Tutorial
- Java-Regular Expression Basic
- java正则表达式; regular expression
- Java 正则表达式(Regular Expression)
- [Leetcode] Regular Expression Matching (Java)
- Regular Expression Matching Leetcode Java
- [LeetCode][Java] Regular Expression Matching
- Regular Expression Matching in Java
- LeetCode : Regular Expression Matching [java]
- 软件开发的新的模式
- 开始我的Blog
- 拍马屁能拍到如此的境界
- delphi的interface编程注意问题
- Automatic Transactions and .NET Framework Classes
- (JAVA)Regular Expression测试
- Delphi自带的SpinEdit控件太丑了,自己写一个替换它
- 将asp权限提到最高
- 利用C++Builder 6 中OLE自动化功能实现调用Word进行报表制作
- SAML简介(beegee译稿)
- 上午跑去单位将佛山公文交换联调了一下,下午继续闭关修炼(CA)
- IT人的通病,你占了几条?〔转自pconline〕
- 完成权限控制中的Group Administration
- 提高写代码的效率