📄 second.java
字号:
/*
* Second.java
*
* Created on 2007年12月8日, 下午2:51
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package org.Adam;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author Administrator
*/
public class Second {
/** Creates a new instance of Second */
public Second() {
}
public static void main(String[] args) {
String redEx="([a-zA-Z]+)\\s+[0-9]{1,2},\\s*[0-9]{4}";
String str="June 26,1951";
Pattern p=Pattern.compile(redEx);
Matcher m=p.matcher(str);
if(!m.find()){
System.out.println("日期格式错误");
return;
}
System.out.println(m.group());
System.out.println(Pattern.matches("[a-zA-Z]+\\s+[0-9]{1,2}.\\s*[0-9]{4}","June 25,1965"));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -