preg_match works only with string


Staff member
I am having a very strange problem in wordpress.

I get a post content as a variable and I do a preg_match on the variable without results. Then when using the string that is the variable, instead of the variable itself, everything works perfect. This is driving me nuts, can anyone help me?

// This doesn't work, I checked a thousand times and inside the $content variable 
// is the same string as I use below
$content = the_content();
preg_match('/<iframe.*src=\\"(.*)\\".*><\\/iframe>/is', $content, $matches);
return $matches;

// This works perfect?
$content = the_content();
preg_match('/<iframe.*src=\\"(.*)\\".*><\\/iframe>/is', "this is a string containing <iframe ...", $matches);
return $matches;