Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
n00b question - how to use this regex code?
Old 11-22-2010, 09:58 AM n00b question - how to use this regex code?
Junior Talker

Posts: 1
Name: Henk
Trades: 0
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:



PHP Code:
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/v/'.$matches[2].'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/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/v/'.$matches[1].'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/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 :shrug:

Thanks in advance, I hope to get this working!
crankyslap is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to n00b question - how to use this regex code?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.07756 seconds with 12 queries