title: RegEx all matches between
body: <p>I'd like to match all <code>foo</code> and <code>bar</code> (those who are only between <code>8</code> characters) in this text <code>foo bar foo 8 bar foo bar 8 foo bar foo</code>.</p>
  
  <p>This is what I tried: <code>8.*(foo|bar).*8</code></p>
  
  <p>The problem is it only matches the last <code>bar</code> as (I believe) the greedy quantifier go as far as he can.</p>
  
  <p>I did my best when trying to search for how to fix this but couldn't end up finding anything, so I'm asking here.</p>
  
  <p>My current RegEx so you can understand what I mean better: <a href="https://regex101.com/r/p0tQws/1" rel="nofollow noreferrer">https://regex101.com/r/p0tQws/1</a></p>