Marco Nätlitz Marco Nätlitz - 7 months ago 14
Java Question

RegExp: Key Value pairs with value lists enclosed by { and } or quotes

I am looking for a regular expression that will capture the following:

  1. key

  2. key=value

  3. key="some \"value\" escaped"

  4. key={value1,value2}

The key/value pair will be joined by a string, so:

key,key1=value1,key2={foo,bar},key3="some description for \"foo\"",...

Currently, I have the following:


It captures (1), (2) and (3) but not (4).

The regular expression will be parsed with Java.

Any ideas?


You can use this longish regex:


RegEx Demo