I have below String which is in the format of key1=value1, key2=value2
which I need to load it in a map (Map
as key=value<
As you said your keys only contain alphanumerics, the following would probably be a good heuristic for splitting:
payload.split("\\s*,\\s*(?=[a-zA-Z0-9_]+\\s*=|$)");
Which will split on probably whitespace framed commas that are followed by the end of the string or an alphanumeric key, optional whitespace and an equals sign.