fork download
  1. /* package whatever; // don't place package name! */
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4. import java.util.*;
  5. import java.lang.*;
  6. import java.io.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13.  
  14.  
  15. String deepak = "\n" +
  16. "\n" +
  17. " ID TYPE USER IDLE\n" +
  18. "\n" +
  19. " 63494 ABC DEEP 3 s\n" +
  20. " -> 70403 ABC DEEAP 0 s\n" +
  21. " 82446 ABC DEEOP 52 min 27 s\n";
  22. System.out.println(deepak);
  23.  
  24. Pattern p = Pattern.compile("(?<= )[0-9]+(?=\\s*ABC\\s*DEEP\\s*[0-9]\\s*s)");
  25. Matcher m = p.matcher(deepak);
  26. while (m.find()) {
  27. System.out.println(m.group());
  28. }
  29. }
  30. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout

    ID     TYPE    USER                            IDLE

    63494  ABC     DEEP                            3 s
 -> 70403  ABC     DEEAP                           0 s
    82446  ABC     DEEOP                           52 min 27 s

63494