Marco Nätlitz Marco Nätlitz - 1 year ago 83
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?

Answer Source

You can use this longish regex:


RegEx Demo

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download