fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.regex.*;
  5.  
  6. import java.lang.*;
  7. import java.io.*;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. // your code goes here
  15. String line = "wall street 4 06:28 07:29 07:59 08:29 08:59 30 19:59 20:29 21:04 22:04 23:04 00:04 00:30";
  16. Pattern pattern = Pattern.compile("(?<=\\d\\s)\\d{2}(?=\\s\\d)");
  17.  
  18. Matcher m = pattern.matcher(line);
  19. while (m.find()) {
  20. int value = Integer.parseInt(m.group().trim());
  21.  
  22. }
  23. line = line.replaceAll("(?<=\\d\\s)\\d{2}(?=\\s\\d)", "").replaceAll(" +", " ");
  24. System.out.println(line);
  25. }
  26. }
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
wall street 4 06:28 07:29 07:59 08:29 08:59 19:59 20:29 21:04 22:04 23:04 00:04 00:30