title: Replacing a property of an object in JSON array of based on another property value
body: <p>I am writing a regex rule for a debugging proxy (could also apply to processing text in Notepad++ or something like that).</p>
  
  <p>I have an array of objects in JSON form and I need to replace one of the values of an object if their other property value matches</p>
  
  <pre><code>[
      { "name": "alpha", /* a lot of omitted properties */, "foo": "bar", /* a lot of omitted properties */},
      { "name": "beta", /* a lot of omitted properties */, "foo": "baz", /* a lot of omitted properties */ },
      { "name": "gamma", /* a lot of omitted properties */, "foo": "bat", /* a lot of omitted properties */ }
  ]
  </code></pre>
  
  <p>In this example I want regex to match objects where foo = baz and replace their name with <code>replacedName</code>, so replacement pattern could be like <code>$1replacedName$2</code></p>
  
  <p>I tried this: (<a href="https://regex101.com/r/gMfXCU/1" rel="nofollow noreferrer">regex101 link</a>)</p>
  
  <pre><code>({\s*"name":\s*")(?:\w+)"([\S\s]+?"foo":\s*"baz".*?})
  </code></pre>
  
  <p>But then the expression matches 1st and 2nd objects, and name of 1st is replaced. How do I make regex stop evaluating next objects?</p>