Friday, May 11, 2012

Java regular expression to extract Date format like April 12, 2012

String s = "Department May 89 , 2012 - May 09 , 2011, June 12, 2011";
        Pattern p = Pattern.compile(
                "(jan|feb|mar|apr|may|jun|jul|aug|sep|nov|dec)[a-z]{0,6}[\\s]*[0-9]{1,2}[\\s]*,[\\s]*[0-9]{4}",
                Pattern.CASE_INSENSITIVE);
        Matcher m = p.matcher(s);
        while (m.find()) {
                System.out.println(m.group(0));
        }


You will get all 3 dates,
image

No comments:

 
Locations of visitors to this page