fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.regex.*;
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String string = "1, 2, acceptline,x,111, 100, , , 20, 20, end\n1, 2, declineline,x,x, 100, 20, , end\n1, 2, 3, acceptline,x,x, 1000, , 40, end";
  13.  
  14. String regex = "\\bacceptline(?:,[^,]*){2},\\s*(\\d+)";
  15. Pattern pattern = Pattern.compile(regex);
  16. Matcher matcher = pattern.matcher(string);
  17.  
  18. while (matcher.find()) {
  19. System.out.println(matcher.group(1));
  20. }
  21. }
  22. }
Success #stdin #stdout 0.1s 52136KB
stdin
Standard input is empty
stdout
100
1000