I want to extract from the string that KEYs are separated from VALUE by a colon (:) and s are separated by a comma (,). The problem is that VALUE may contain a comma. As an example:
category:information technology, computer,publisher:Elsevier (EV),subject:Ecology, Evolution, Behavior and Systematics
In this example, the KEYS to be extracted are: category, publisher, and subject. The end result should be as follows:
category = information technology, computer
publisher = Elsevier (EV)
subject = Ecology, Evolution, Behavior and Systematics
I tried to write a recursive regular expression, but it does not work:
(category|publisher|subject):(.*?)(?:,(?R)|.?)
Can someone help solve this problem. Thanks.
source
share