fork(3) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.util.regex.Pattern;
  4. import java.util.regex.Matcher;
  5.  
  6. class Main
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. Pattern pattern = Pattern.compile("(?:Active Phone Lines:|\\G)[\\s,]*([0-9]{4})");
  11. String test = "User Names: bob, jill, toni, tom"+
  12. "Active Phone Lines: 1010, 2020, 3030, 4040, 5050, 6060, 7070"+
  13. "Inactive Phone Lines: 1111, 2222, 3333, 4444, 5555";
  14. Matcher matcher = pattern.matcher(test);
  15. while (matcher.find()) {
  16. System.out.println(matcher.group(1));
  17. }
  18. }
  19. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
1010
2020
3030
4040
5050
6060
7070