fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.regex.*;
  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. public static void main (String[] args) throws java.lang.Exception {
  11. String test= "ytrt.ytrwyt.ytreytre.test1,0,2,0"
  12. +"sfgtr.ytyer.qdfre.uyeyrt.test2,0,8,0"
  13. +"sfgtr.ytyer.qdfre.uyeyrt.test3,0,3,0";
  14. String pattern = "(?<=test[123],[^,],)\\d+";
  15.  
  16. Pattern pr = Pattern.compile(pattern);
  17.  
  18. Matcher match = pr.matcher(test);
  19. System.out.println();
  20. while (match.find()) {
  21. System.out.println("Found: " + match.group());
  22. }
  23. }
  24. }
  25.  
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
Found: 2
Found: 8
Found: 3