Java tutorial
import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] args) { String query = "name==p==?header=hello?aname=?????lname=lastname"; String[] params = query.split("\\?"); Map<String, String> map = new HashMap<String, String>(); for (String param : params) { String name = param.split("=")[0]; String value = param.substring(name.length(), param.length()); map.put(name, value); System.out.println(name); if (name.equals("")) { value += "?"; } System.out.println(value.replaceAll(" ", "")); } } }