crankyslap Posted November 22, 2010 Share Posted November 22, 2010 Sorry for nubbing up the forums, but I'm quite anxious to ge this working and there aren't really any n00b-friendly guides out there. As you can see right here, I fetch video's from tgn.tv's youtube feed. Now, I need that youtube link at the bottom, to convert to an embed so the actual video is shown on my page. For this to happen, I searched & found this basic Regex: ------------------------- find :#(?:<\>]+href=\")?(?:http://)?((?:[a-zA-Z]{1,4}\.)?youtube.com/(?:watch)?\?v=(.{11}?))[^"]*(?:\"[^\<\>]*>)?([^\<\>]*)(??# replace : '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/watch?v='.$matches[2].'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/watch?v='.$matches[2].'" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>' find :#\[youtube\]([^\[\]]+)\[/youtube\]# replace : '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/watch?v='.$matches[1].'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/watch?v='.$matches[1].'" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>' ------------------------- However, I believe I also need to strip "&feature=youtube_gdata" and the text "Article Source" that precedes the link. I also haven't got a clue how to actually make this work for me. I tried to go in cold-turkey and just paste the snippet in header.php in wordpress, but naturally, this gave an error. Sorry if the explenation is right there, out in the open. I have searched, but I have not found it. If there is someone here who could pherhaps solve the aformentioned problem (and pherhaps bold the changes made?), and tell me how to get the code working, it would be most appreciated. I know I'm not supposed to just ask people to do stuff for me, but I learn best by example, as right now this whole regex thing is Chinese to me Thanks in advance, I hope to get this working! Quote Link to comment https://forums.phpfreaks.com/topic/219462-n00b-question-how-to-use-this-regex-code/ Share on other sites More sharing options...
tecno40 Posted November 23, 2010 Share Posted November 23, 2010 There might be an easier way to do this. What is the URL for that feed? Quote Link to comment https://forums.phpfreaks.com/topic/219462-n00b-question-how-to-use-this-regex-code/#findComment-1138241 Share on other sites More sharing options...
sasa Posted November 24, 2010 Share Posted November 24, 2010 if you want to someone help you post source code of page not picture of it Quote Link to comment https://forums.phpfreaks.com/topic/219462-n00b-question-how-to-use-this-regex-code/#findComment-1138845 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.