title: regexp - match pattern and prefix before pattern
body: <p>I need to match a specific pattern</p>
  
  <pre><code>(?&lt;!\d|\d )(?:dk)?(\d{2})\D?(\d{2})\D?(\d{2})\D?(\d{2})(?!\d)
  </code></pre>
  
  <p>eg.</p>
  
  <pre><code>dk30344510
  dk30 34 45 10
  30344510
  30 34 45 10
  </code></pre>
  
  <p>But I also need to fetch the "prefix" string before the pattern</p>
  
  <p>This is my solution, but it doesn't always work</p>
  
  <pre><code>^(.*)(?&lt;!\d|\d )(?:dk)?(\d{2})\D?(\d{2})\D?(\d{2})\D?(\d{2})(?!\d)
  </code></pre>
  
  <p>It's hard to explain so check it here.</p>
  
  <p><a href="https://regex101.com/r/fM1xD3/2" rel="nofollow">https://regex101.com/r/fM1xD3/2</a></p>
  
  <p>It's too "greedy" and match multiple pattern in the string. The actual match is here a part of the "prefix" of the second match</p>
  
  <p>The example should output two matches. One with <code>dk30344510</code> and <code>62226420</code></p>
  
  <p>The example should output <code>CVR-nr.</code> as prefix and <code>dk30344510</code> as the pattern and second match should be <code>/ Tlf.</code> as prefix and <code>62226420</code> as the pattern</p>