fork download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7.  
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. final String regex = "\\d{4}/\\d{2}/\\w/\\w/\\d{2}";
  13. final String string = "9708/32/M/J/15\n\n"
  14. + "awfawf9708/32/M/J/15awfafwaf";
  15.  
  16. final Pattern pattern = Pattern.compile(regex);
  17. final Matcher matcher = pattern.matcher(string);
  18.  
  19. while (matcher.find()) {
  20. System.out.println(matcher.group(0));
  21. }
  22. }
  23. }
Success #stdin #stdout 0.12s 33752KB
stdin
Standard input is empty
stdout
9708/32/M/J/15
9708/32/M/J/15