java 正则表达式 字符串中提取日期 例如:某一节目第20140502期
package p1;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RunnableTicket
{
public static void main ( String[] args )
{
String reg = "[1-9]\\d{3}(((0[13578]|1[02])([0-2]\\d|3[01]))|((0[469]|11)([0-2]\\d|30))|(02([01]\\d|2[0-8])))";
String str = "某一节目第20140502期";
Pattern pattern = Pattern.compile (reg);
Matcher matcher = pattern.matcher (str);
while (matcher.find ())
{
System.out.println (matcher.group ());
}
}
}