title: php preg replace not replacing variation of link
body: <p><strong>UPDATE SOLVED (added answer here so you don't waste your time) this is just to help others in the same pickle</strong></p>
  
  <p>I have just noticed the link text is being cut in the post turning the html portion to:</p>
  
  <pre><code>&lt;a href="https://twitter.com/digitalOcean/status/723205273226190848" target="_blank"&gt;https://twitter.com/digitalOcean/sta...05273226190848&lt;/a&gt;
  </code></pre>
  
  <p>Thus loosing the <code>/status</code>portion of my replace</p>
  
  <p>Changing my expression to</p>
  
  <pre><code>~(&lt;a href="https?://twitter.com)/(.*)/status/(.*)"&gt;(https?://twitter.com)/(.*)&lt;\/a&gt;~
  </code></pre>
  
  <p>solved the problem, sorry about that guys =)</p>
  
  <p><strong>original question to help others</strong></p>
  
  <p>I posted another question about my plugin using preg_replace only to get no replies, so I set out to learn some more (always a good idea) ;)</p>
  
  <p>I managed to come up with a better solution but I need a little help.  This is my new code:</p>
  
  <pre><code>// embed tweet https://twitter.com/DrCustUmz/status/726561400617840641
  $embed_tweet =  '
    &lt;blockquote class="twitter-tweet" data-cards="hidden" data-lang="en"&gt;
      &lt;a href="https://twitter.com/\2/status/\3"&gt;&lt;/a&gt;
    &lt;/blockquote&gt;
  ';
  $this-&gt;post['message'] = preg_replace('~(&lt;a href="https?://twitter.com)/(.*)/status/(.*)"&gt;(https?://twitter.com)/(.*)/status/(.*)&lt;\/a&gt;~', $embed_tweet, $this-&gt;post['message']);
  
  // embed vine http://vine.co/v/bXZre5gtYgT/embed/postcard
  
  $embed_player =  '&lt;iframe src="https://vine.co/v/\\4" width="480" height="480" frameborder="0"&gt;&lt;/iframe&gt;';
  
  $this-&gt;post['message'] = preg_replace('~(&lt;a href="https?://vine.co)/v/(.*)"&gt;(https?://vine.co)/v/(.*)&lt;\/a&gt;~', $embed_player, $this-&gt;post['message']);
  </code></pre>
  
  <p><strong>So whats it do?</strong></p>
  
  <p>Good question, on my site when a user posts a link, once the post is submitted it formats it to a href. I.E. Posting <code>http://vine.co/v/bXZre5gtYgT/embed/postcard</code> becomes <code>&lt;a href="http://vine.co/v/bXZre5gtYgT/embed/postcard" target="_blank"&gt;http://vine.co/v/bXZre5gtYgT/embed/postcard&lt;/a&gt;</code></p>
  
  <p>What this replace does is finds twitter and vine links and auto inserts the embed code for that post.</p>
  
  <p><strong>So whats wrong?</strong></p>
  
  <p>The Vine replace I have yet to find any errors with, but the Twitter portion doesn't want to embed the following link:</p>
  
  <pre><code>https://twitter.com/digitalOcean/status/723205273226190848
  </code></pre>
  
  <p>But does replace:</p>
  
  <pre><code>https://twitter.com/DrCustUmz/status/726561400617840641
  and
  https://twitter.com/vBulletin/status/697116051079692288
  </code></pre>
  
  <p>I can't for the life of me figure this out, as there are no differences in the links other than username and post number. So maybe something is wrong with my expression?</p>
  
  <p>Again here is the link to replace:</p>
  
  <pre><code> https://twitter.com/digitalOcean/status/723205273226190848
  </code></pre>
  
  <p>And here is my regular expression:</p>
  
  <pre><code>~(&lt;a href="https?://twitter.com)/(.*)/status/(.*)"&gt;(https?://twitter.com)/(.*)/status/(.*)&lt;\/a&gt;~
  </code></pre>
  
  <p><strong>I didn't exactly see a question...</strong></p>
  
  <p>Yeah... about that, I tend to forget asking a question specifically I figure you guys know what I'm trying to figure out lol</p>
  
  <p>So I guess... Why does my <code>preg_replace</code> work for some links but not all?</p>
  
  <p>Any help with this would be greatly appreciated :)</p>
  
  <p><em>This is not a duplicate of my previous question, I have got pretty much all of that question figured out on my own and am almost ready to answer it myself.</em></p>