I have the following regular expression which is supposed to match remove operations from a JSON PATCH request.
({\s*\"op\"\s*:\s*\"remove\",\s*\"path\"\s*:\s*\".\",\s\"value\"\s*:\s*([{.}]|\".\")\s*})
If I apply this regular expression to
[{"op":"remove","path":"/emailAddresses","value":[{"emailType":{"code":"E","codeSystemId":"hl7.org"},"emailAddress":"abc@abcdef.com","idWithSource":"abc|817921"}]},{"op":"replace","path":"/emailAddresses","value":[{"idWithSource":"abc|822222"}]}]
I get the following as a match.
{"op":"remove","path":"/emailAddresses","value":[{"emailType":{"code":"E","codeSystemId":"hl7.org"},"emailAddress":"abc@abcdef.com","idWithSource":"abc|817921"}]},{"op":"replace","path":"/emailAddresses","value":[{"idWithSource":"abc|822222"}
It needs to be just the following:
{"op":"remove","path":"/emailAddresses","value":[{"emailType":{"code":"E","codeSystemId":"hl7.org"},"emailAddress":"abc@abcde.com","idWithSource":"abc|817921"}]}
If I apply this regular expression to
[{ "op": "remove", "path": "/drugName", "value": "aadadada" },{ "op": "replace", "path": "/drugName", "value": "Tylenol" }]
I get the following as a match.
{ "op": "remove", "path": "/drugName", "value": "aadadada" },{ "op": "replace", "path": "/drugName", "value": "Tylenol" }
It needs to be just the following:
{ "op": "remove", "path": "/drugName", "value": "aadadada" }
These two examples are the formats that the value field can be in. Does anyone have any advice on how to fix this?