fork download
  1. import java.util.*;
  2. import java.util.regex.*;
  3. import java.lang.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Pattern p = Pattern.compile("Page (?<startPage>\\d+) of (?<totalPages>\\d+)");
  10. String text = "Page 14 of 203";
  11. Matcher m = p.matcher(text);
  12. if (m.find()) {
  13. System.out.println(m.group("startPage"));
  14. System.out.println(m.group("totalPages"));
  15. }
  16. }
  17. }
Success #stdin #stdout 0.1s 53708KB
stdin
Standard input is empty
stdout
14
203