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.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13.  
  14. String myString = "<http://v...content-available-to-author-only...t.com/v4/competitive/search?Authorization={API_KEY}&mobileReady=true&qd=between:20150101000000,20150101060000&onlyCommercial=true&hasCreative=true&page=0&per_page=100>; rel=\"first\",<http://v...content-available-to-author-only...t.com/v4/competitive/search?Authorization={API_KEY}&mobileReady=true&qd=between:20150101000000,20150101060000&onlyCommercial=true&hasCreative=true&page=20&per_page=100>; rel=\"last\",<http://v...content-available-to-author-only...t.com/v4/competitive/search?Authorization={API_KEY}&mobileReady=true&qd=between:20150101000000,20150101060000&onlyCommercial=true&hasCreative=true&page=1&per_page=100>; rel=\"next\"";
  15. try {
  16. Pattern regex = Pattern.compile("\"last\",(.*?)$");
  17. Matcher regexMatcher = regex.matcher(myString);
  18. if(regexMatcher.find()) {
  19. String next = regexMatcher.group(1);
  20. System.out.println(next );
  21. }
  22. } catch (PatternSyntaxException ex) {
  23. // Syntax error in the regular expression
  24. }
  25.  
  26. }
  27. }
Success #stdin #stdout 0.11s 320576KB
stdin
Standard input is empty
stdout
<http://v...content-available-to-author-only...t.com/v4/competitive/search?Authorization={API_KEY}&mobileReady=true&qd=between:20150101000000,20150101060000&onlyCommercial=true&hasCreative=true&page=1&per_page=100>; rel="next"