fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. import java.util.regex.Matcher;
  5. import java.util.regex.Pattern;
  6.  
  7. class Main
  8. {
  9. public static final String str = "{\n\"resultCount\":12,\n\"results\": [blah blah..";
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Pattern pattern = Pattern.compile("resultCount\":\\s*(\\d+)");
  13.  
  14. Matcher matcher = pattern.matcher(str);
  15.  
  16. while (matcher.find()) {
  17. System.out.println(matcher.group(1));
  18. }
  19. }
  20. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
12