Gissipi_453 Gissipi_453 - 1 year ago 137
Javascript Question

Regex for key value pair

I have a regex


that matches key value pair like these -



But the regex match fails if the key and value are within paranthesis like these -



What modification can be done to make the regex match key and value within paranthesis also ?

Answer Source

You can use optional quotes on either side of key-value pairs like this:


RegEx Demo

Take note of group ("?) that captured an empty string or a double quote. On the other side we use a back-reference \1 of this group for closing quote.

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