title: Regular expression for a polish phone number
body: <p>I'm working on a <strong>regular expression</strong> to find polish phone numbers in a long string. There might be <code>+48</code>, <code>0048</code>, <code>48</code> (in brackets on not) followed by 9 digits with spaces in between.  </p>
  
  <p>The first idea was:</p>
  
  <pre><code>(\(?(\+|00)?48\)?)?[ -]?\d{3}[ -]?\d{3}[ -]?\d{3}
  </code></pre>
  
  <p>This captures things like <code>+48 123 456 789</code> and <code>123456789</code> but will also find 2 phone numbers in <code>1234567899876543211</code> - this is not acceptable. So I added word boundaries: </p>
  
  <pre><code>\b(\(?(\+|00)?48\)?)?[ -]?\d{3}[ -]?\d{3}[ -]?\d{3}\b
  </code></pre>
  
  <p>But this regex, in a string such as <code>(+48) 123 456 789</code> will only capture <code>48) 123 456 789</code>. Why is the beginning omitted?  </p>
  
  <p>(<a href="https://regex101.com/r/irmjnT/5" rel="nofollow noreferrer">regex101</a> with examples of what should match/shouldn't match)</p>