fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.regex.Matcher;
  4. import java.util.regex.Pattern;
  5.  
  6. /* Name of the class has to be "Main" only if the class is public. */
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. String input = "Must be submitted, before twelve o'clock noon on wednesday, june 19, 2013, at which time it will be read.";
  12. String regex = "^(?=.*(due|submit|deadline)[^\\d]*)"
  13. + ".*?(january|february|march|april|may|june|july|august|september|october|november|december)"
  14. + "\\s*(0?[1-9]|[12][0-9]|3[01])(th|rd|nd|st)*,*\\s*((19|20)\\d\\d)";
  15. Pattern p = Pattern.compile(regex);
  16. Matcher m = p.matcher(input);
  17. if(m.find()){
  18. System.out.println(">"+m.group());
  19. System.out.println(">"+m.group(1));
  20. System.out.println(">"+m.group(2));
  21. System.out.println(">"+m.group(3));
  22. System.out.println(">"+m.group(4));
  23. System.out.println(">"+m.group(5));
  24. }
  25. }
  26. }
Success #stdin #stdout 0.08s 381184KB
stdin
Standard input is empty
stdout
>Must be submitted, before twelve o'clock noon on wednesday, june 19, 2013
>submit
>june
>19
>null
>2013