// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class QueryStringParse {
    private static final Pattern p = Pattern.compile("([A-Za-z][A-Za-z0-9]*)(?:=)([^&]*)");
    public static void parse(String html) {
        Matcher m = p.matcher(html);
        while(m.find()) {
            System.out.println(m.group(1) + "=" + m.group(2));
        }
    }
    public static void main(String[] args) {
        parse("?id=123&type=comment");
    }
}
