fork download
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.regex.Matcher;
  4. import java.util.regex.Pattern;
  5.  
  6. class Main {
  7.  
  8. public static void main(String[] args) throws java.lang.Exception {
  9. List<String> myListe = new ArrayList<String>();
  10. String horaires = "Lun. 08:00 - 12:15 13:15 - 16:15 Mar. 08:00 - 12:15 13:15 - 16:15 Mer. 08:00 - 12:15 13:15 - 16:15 Jeu. 08:00 - 12:15 13:15 - 16:15 Ven. 08:00 - 12:15 13:15 - 16:15 ";
  11. final Pattern pattern = Pattern.compile("((Lun|Mar|Mer|Jeu|Ven|Sam). [0-9 \\-:]*)");
  12. final Matcher matcher = pattern.matcher(horaires);
  13. while (matcher.find()) {
  14. myListe.add(matcher.group());
  15.  
  16. }
  17. for (String str : myListe) {
  18. System.out.println(str);
  19. }
  20. }
  21. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
Lun. 08:00 - 12:15 13:15 - 16:15 
Mar. 08:00 - 12:15 13:15 - 16:15 
Mer. 08:00 - 12:15 13:15 - 16:15 
Jeu. 08:00 - 12:15 13:15 - 16:15 
Ven. 08:00 - 12:15 13:15 - 16:15