// 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) 
public class Parse1 {
   public static void main(String[] args) {
      process("(name=id,type=string),(name=age,type=integer)");
   }
   private final static String NAME = "name=";
   private final static String TYPE = "type=";
   public static void process(String s) {
      int ix = 0;
      while (ix < s.length()) {
         int ixname = s.indexOf(NAME, ix);
         if (ixname <= 0)
            ixname = s.length();
         int ixtype = s.indexOf(TYPE, ix);
         if (ixtype <= 0)
            ixtype = s.length();
         if (ixname < ixtype) {
            int ixend = s.indexOf(",", ixname);
            String name = s.substring(ixname + NAME.length(), ixend);
            System.out.println("name: " + name);
            ix = ixend;
         } else if (ixtype < ixname) {
            int ixend = s.indexOf(")", ixtype);
            String name = s.substring(ixtype + TYPE.length(), ixend);
            System.out.println("type: " + name);
            ix = ixend;
         } else {
            ix = s.length();
         }
      }
   }
}
