title: How can I search for a matching substring in a file with regex and return only the substring?
body: <p>I have a file that is 50 MB and only one line. It is corrupt json and I am searching for a substring.</p>
  <p>I have a problem with grep that it does not support lazy search in the default syntax. And pearl syntax doesn't seem to be supported on MacOS.</p>
  <p>Here is a basic expression that does work but only returns the id, while I need the entire object</p>
  <p><code>grep -o  '1234' largefile</code></p>
  <p>Here are some things I tried that did not work</p>
  <p><code>grep -oP '1234.*?globalId' largefile </code></p>
  <blockquote>
  <p>P not supported</p>
  </blockquote>
  <p><code>grep -F '1234' largefile | grep -o -E '.{30} 1234.{500}'</code></p>
  <blockquote>
  <p>invalid repetition count(s)</p>
  </blockquote>
  <p><code>grep -o  '1234.{100}' largefile</code></p>
  <blockquote>
  <p>doesn't return anything</p>
  </blockquote>
  <p>How can I do this search? It doens't need to be grep. I sometimes read about <code>awk</code>, <code>perl</code>, <code>ripgrep</code> and other stuff that I have never had reason to try.</p>