second.java
来自「java netbeans 学习程序合集」· Java 代码 · 共 37 行
JAVA
37 行
/*
* 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 + =
减小字号Ctrl + -
显示快捷键?