, - .
/<object(.*)<\/object>/m
.
:
http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
Update:
m ( ):
m (PCRE_MULTILINE) PCRE "" ( ). " " metacharacter (^) , " line" metacharacter ($) ( D ). , Perl. , " " " " , . Perl/m. \n " ^ $ , .
( .)
s, . .
, , . , .
$input = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="250" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=9048799&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="250" src="http://vimeo.com/moogaloop.swf?clip_id=9048799&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
$input2 = '<object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5630744&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00ADEF&fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5630744&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00ADEF&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>';
$matches = array();
preg_match_all('/<object(.*)<\/object>/', $input, $matches);
echo '<br />$input<pre>';
var_dump($matches);
echo '</pre>';
$matches2 = array();
preg_match_all('/<object(.*)<\/object>/', $input2, $matches2);
echo '<br />$input2<pre>';
var_dump($matches2);
echo '</pre>';
:
?
ob_start();
ob_end_clean();
. (. .)
0, , null?
if(empty($the_video)){ $the_video = 0; }
null , . , , $post WordPress. ( , .)
function catch_that_video()
{
global $post;
$the_video = null;
$vid_matches = array();
if(preg_match('/<object.*<\/object>/', $post->post_content, $vid_matches))
{
$the_video = $vid_matches[0];
}
return $the_video;
}
, preg_match preg_match_all, . , preg_match_all, . , . ( s , , , <object> </object>. <object>...</object>.)
, 2- . . , - VIM Linux, `^ M '\r . html ? , ?