Java tutorial
//package com.java2s; //License from project: Apache License import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static Map<String, String> parseCommaDelimitedProps(String s) { if (s == null) return null; Map<String, String> props = new HashMap<String, String>(); Pattern p = Pattern.compile("\\s*([^=\\s]+)\\s*=\\s*([^=\\s,]+)\\s*,?"); //Pattern.compile("\\s*([^=\\s]+)\\s*=\\s([^=\\s]+)\\s*,?"); Matcher matcher = p.matcher(s); while (matcher.find()) { props.put(matcher.group(1), matcher.group(2)); } return props; } }