title: Regex to match as few many times as possible (lazy) using grep
body: <p>I'm quite new to regex. I have the following simple line in a txt file.</p>
  
  <pre><code>This one has some different PATTERNs, including PTTRN, and PTN, then it repeats PTTRN and PATTERN
  </code></pre>
  
  <p>Using <code>grep -E</code>, I want to match everything between the first PATTERN and the first PTTRN without extending the match to the second PTTRN.</p>
  
  <p>I tried doing</p>
  
  <pre><code>PATTERN.*?PTTRN
  </code></pre>
  
  <p>That seems to work in <a href="https://regex101.com/r/qI4aA6/8" rel="nofollow">https://regex101.com/r/qI4aA6/8</a></p>
  
  <p>But when I try using it in the terminal with grep, it colours all the way down to the second PTTRN, that is</p>
  
  <pre><code>PATTERNs, including PTTRN, and PTN, then it repeats PTTRN
  </code></pre>
  
  <p>Besides, I'm using the default grep (gnu grep) on my ubuntu system.</p>