title: regex: matching only first occurrence per line
body: <p>I want to select the first " - " from each line:</p>
  
  <pre><code>123 - foo - asdf
  234 - bar - abcdefg
  345 - foobar and hello world
  </code></pre>
  
  <p>If you use <code>\s-\s</code> it will select both occurrences from the first 2 lines.</p>
  
  <p>So what I want is this:</p>
  
  <p><a href="https://i.stack.imgur.com/gd7Tc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gd7Tc.png" alt="enter image description here"></a></p>
  
  <p>I want 1 space, followed by a hyphen, followed by another space <code>\s-\s</code>, not just the hyphen and replace it with <code>test</code>, which is for the first line: <code>123testfoo - asdf</code>.</p>
  
  <p>I think you have to add a <code>?</code> to make it non-greedy, but I don't know how.</p>
  
  <p>Thanks.</p>
  
  <p>Edit: <strong>Here's the goal</strong>:</p>
  
  <p>I've got a huge file of IDs and Texts and I want to create an MySQL INSERT statement. So I want to replace the first <code>\s-\s</code> occurrence with <code>, '</code> (in that part).</p>