UPDATE SOLVED (added answer here so you don't waste your time) this is just to help others in the same pickle
I have just noticed the link text is being cut in the post turning the html portion to:
<a href="https://twitter.com/digitalOcean/status/723205273226190848" target="_blank">https://twitter.com/digitalOcean/sta...05273226190848</a>
Thus loosing the /statusportion of my replace
Changing my expression to
~(<a href="https?://twitter.com)/(.*)/status/(.*)">(https?://twitter.com)/(.*)<\/a>~
solved the problem, sorry about that guys =)
original question to help others
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) ;)
I managed to come up with a better solution but I need a little help. This is my new code:
// embed tweet https://twitter.com/DrCustUmz/status/726561400617840641
$embed_tweet = '
<blockquote class="twitter-tweet" data-cards="hidden" data-lang="en">
<a href="https://twitter.com/\2/status/\3"></a>
</blockquote>
';
$this->post['message'] = preg_replace('~(<a href="https?://twitter.com)/(.*)/status/(.*)">(https?://twitter.com)/(.*)/status/(.*)<\/a>~', $embed_tweet, $this->post['message']);
// embed vine http://vine.co/v/bXZre5gtYgT/embed/postcard
$embed_player = '<iframe src="https://vine.co/v/\\4" width="480" height="480" frameborder="0"></iframe>';
$this->post['message'] = preg_replace('~(<a href="https?://vine.co)/v/(.*)">(https?://vine.co)/v/(.*)<\/a>~', $embed_player, $this->post['message']);
So whats it do?
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 http://vine.co/v/bXZre5gtYgT/embed/postcard becomes <a href="http://vine.co/v/bXZre5gtYgT/embed/postcard" target="_blank">http://vine.co/v/bXZre5gtYgT/embed/postcard</a>
What this replace does is finds twitter and vine links and auto inserts the embed code for that post.
So whats wrong?
The Vine replace I have yet to find any errors with, but the Twitter portion doesn't want to embed the following link:
https://twitter.com/digitalOcean/status/723205273226190848
But does replace:
https://twitter.com/DrCustUmz/status/726561400617840641
and
https://twitter.com/vBulletin/status/697116051079692288
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?
Again here is the link to replace:
https://twitter.com/digitalOcean/status/723205273226190848
And here is my regular expression:
~(<a href="https?://twitter.com)/(.*)/status/(.*)">(https?://twitter.com)/(.*)/status/(.*)<\/a>~
I didn't exactly see a question...
Yeah... about that, I tend to forget asking a question specifically I figure you guys know what I'm trying to figure out lol
So I guess... Why does my preg_replace work for some links but not all?
Any help with this would be greatly appreciated :)
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.