title: Why is regex matching ":www.xxx.com"
body: <p>I got the following code snipped from a popular website, for PHP regex validation. </p>
  
  <p>I'm a novice and am playing around with regex. When I put a colon ":" in front of the URL, for $website as below (":www.xxx.com"), the expression still matches. I can't figure out why this should match. (for instance, $website = "zwww.xxx.com" doesn't match, which is expected). I tried regex 101, and thought the behavior might have something to do with the \b at the beginning of the regex, but even when I remove the \b, it still matches on ":www.xxx.com" or "&amp;www.xxx.com", etc.) Many thanks for explaining!</p>
  
  <pre><code>    &lt;?php
      $website = ":www.xxx.com";
      if (preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&amp;@#\/%?=~_|!:,.;]*
          [-a-z0-9+&amp;@#\/%=~_|]/i",$website)) {
          echo "Matched!";
      } else {
          echo "Not Matched!";
      }
      ?&gt;
  </code></pre>