fork(2) 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. import java.net.*;
  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. URL aURL = new URL("http://e...content-available-to-author-only...e.com:80/docs/books/tutorial"
  14. + "/index.html?&&NAME=name 1&&NAME=name & 2&type=1");
  15. String str = aURL.getQuery();
  16. //System.out.println(str);
  17. String rx = "&(&.*?)=(.*?)(?=&\\S|$)";
  18. Pattern ptrn = Pattern.compile(rx);
  19. Matcher m = ptrn.matcher(str);
  20. while (m.find()) {
  21. System.out.println(m.group(2));
  22. }
  23. }
  24. }
Success #stdin #stdout 0.1s 320320KB
stdin
Standard input is empty
stdout
name 1
name & 2