0

I need to be able to match and mask properties in a json string that is represented as a quote escaped string.

I have come up with the following regex, (?<="transactionId\\":\\".*)\w but it seems to match all instances after the initial match. my intention is to only match the value for transactionId.

{
  "Type": "Notification", 
  "MessageId": "a2d65e5b-5c7b-5b89-9bce-07539ead41fa",
  "Message": "{\"context\":{\"transactionId\":\"93236388\",\"orderOriginId\":\"xxx-xxx\",\"sector\":\"xxx\",\"storeId\":\"xxx\"}
}

enter image description here

Test

Farhad-Taran
  • 5,616
  • 12
  • 56
  • 110

1 Answers1

1
(?<="transactionId\\":\\"[^,]*)\w

Your .* was the problem - greedy.

tink
  • 11,396
  • 4
  • 38
  • 45