pspcrazy Posted May 25, 2009 Share Posted May 25, 2009 Hi I'm trying to get wordpress to replace the flv urls in my posts that are between [flv][/flv] tags with the ###URL### in the code. A flv url is something like this: http://v4.crunchyroll.com/user7/7/p/5/q/7p5qrn4513q1po75q5o/video.flv // FLV Player Code define("FLV_WIDTH", 540); define("FLV_HEIGHT", 438); define("FLV_REGEXP", "/\[flv\]([_A-Za-z0-9-]+)\[\/flv\]/"); define("FLV_TARGET", "<embed flashvars=\"&file=###URL###&autostart=false&skin=/modieus.swf\" allowfullscreen=\"true\" allowscriptaccess=\"always\" quality=\"high\" name=\"mpl\" id=\"mpl\" src=\"http://www.animecrazy.net/player.swf\" type=\"application/x-shockwave-flash\" width=\"540\" height=\"438\">"); function flv_plugin_callback($match) { $output = FLV_TARGET; $output = str_replace("###URL###", $match[1], $output); return ($output); } function flv_plugin($content) { return preg_replace_callback(FLV_REGEXP, 'flv_plugin_callback', $content); } add_filter('the_content', 'flv_plugin'); add_filter('comment_text', 'flv_plugin'); Anyone have any ideas to make this work? It works just fine if I don't use the url and use this code for things like video ids. But once I try url's or thing that have slashes, periods, colons in them it won't work. Thanks for any help or fixes to this. Quote Link to comment https://forums.phpfreaks.com/topic/159628-solved-need-some-help-with-strings-and-matching/ Share on other sites More sharing options...
MadTechie Posted May 25, 2009 Share Posted May 25, 2009 define("FLV_REGEXP", "/\[flv\]([_A-Za-z0-9-]+)\[\/flv\]/"); won't work, your missing dots and slashes and % etc try this define("FLV_REGEXP", '%\[flv\](.*?)\[/flv\]%is'); Quote Link to comment https://forums.phpfreaks.com/topic/159628-solved-need-some-help-with-strings-and-matching/#findComment-841976 Share on other sites More sharing options...
pspcrazy Posted May 26, 2009 Author Share Posted May 26, 2009 Thanks a ton, that did the trick Appreciate it! Quote Link to comment https://forums.phpfreaks.com/topic/159628-solved-need-some-help-with-strings-and-matching/#findComment-841989 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.