title: How can I make a group optional in preg_replace?
body: <p>I'm trying to replace:
  <code>*facebook.com/</code>
  with <code>http://graph.facebook.com/</code></p>
  
  <p>I need to be able to group anything before the <code>facebook.com</code> part into an optional group.
  <br>I can't just replace <code>facebook.com</code> with <code>graph.facebook.com</code> because the incoming URL may contain <code>https</code>.</p>
  
  <p>Here's what I have but misses anything that doesn't have <code>http[s]://</code>.</p>
  
  <pre><code>&lt;?php
  $fb_url = preg_replace('/http[s]*:\/\/[www.]*facebook.com\//', 'http://graph.facebook.com/', 'facebook.com/some/segments');
  echo $fb_url;
  ?&gt;
  </code></pre>