What’s the Java regular expression that captures the entire key-value list (shown in bold in the example below)?
foo bar k0=v0, k1=v1, k2=v2 foo bar
The keys and values do not contain whitespace characters, , or =.
I’ve tried: (([^\s,=]+=[^\s,=]+),?)+ at Regular Expression Test Page for Java, but it gives me groups of the individual equalities (k0=v0, etc) instead of the entire string. Why is that? and how do I fix it?
Your regexp does not allow spaces. If you want it to also include spaces, you can’t get rid of
"foo bar"around it (it will assume it’s a part of a key or value). If you just want to allow spaces after a comma, try this: