Question : Grabbing some word using regular expressions

<embed src="http://www.metacafe.com/fplayer/4812946/the_sorcerers_apprentice_the_mop_scene.swf" width="400" height="345" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_4812946"> </embed><br><font size = 1><a href="http://www.metacafe.com/watch/4812946/the_sorcerers_apprentice_the_mop_scene/">THE SORCERER'S APPRENTICE: The Mop Scene</a> - Watch more top selected videos about: <a href="https://www.metacafe.com/topics/The_Sorcerer's_Apprentice_(2010_film)/" title="The_Sorcerer's_Apprentice_(2010_film)">The_Sorcerer's_Apprentice_(2010_film)</a>, <a href="https://www.metacafe.com/topics/Nicolas_Cage/" title="Nicolas_Cage">Nicolas_Cage</a>, <a href="https://www.metacafe.com/topics/Jay_Baruchel/" title="Jay_Baruchel">Jay_Baruchel</a>

from this code "http://www.metacafe.com/fplayer/4812946/the_sorcerers_apprentice_the_mop_scene.swf" how can I grab this number "481294" from that code?

Answer : Grabbing some word using regular expressions

Hi,

Please have a look at the following example using preg_match.

Hope this helps,

John
1:
2:
3:
4:
5:
6:
<?php
$video = '<embed src="http://www.metacafe.com/fplayer/4812946/the_sorcerers_apprentice_the_mop_scene.swf" width="400" height="345" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_4812946"> </embed><br><font size = 1><a href="http://www.metacafe.com/watch/4812946/the_sorcerers_apprentice_the_mop_scene/">THE SORCERER\'S APPRENTICE: The Mop Scene</a> - Watch more top selected videos about: <a href="https://www.metacafe.com/topics/The_Sorcerer\'s_Apprentice_(2010_film)/" title="The_Sorcerer\'s_Apprentice_(2010_film)">The_Sorcerer\'s_Apprentice_(2010_film)</a>, <a href="https://www.metacafe.com/topics/Nicolas_Cage/" title="Nicolas_Cage">Nicolas_Cage</a>, <a href="https://www.metacafe.com/topics/Jay_Baruchel/" title="Jay_Baruchel">Jay_Baruchel</a>';

preg_match('/fplayer\/(.*?)\//',$video,$match);
print_r($match[1]);
?>
Random Solutions  
 
programming4us programming4us