fork download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3.  
  4. class Test {
  5. public static void main (String[] args) throws java.lang.Exception
  6. {
  7. 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";
  8. System.out.println( "Input: " + line );
  9. Pattern pattern = Pattern.compile("(?<=\\d\\s)\\d{2}(?=\\s\\d)");
  10. Matcher m = pattern.matcher(line);
  11. while (m.find()) {
  12. int value = Integer.parseInt(m.group().trim());
  13. line = m.replaceFirst("");
  14. System.out.println( "Output: " + line );
  15. }
  16. }
  17. }
Success #stdin #stdout 0.09s 321344KB
stdin
Standard input is empty
stdout
Input:  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
Output: 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