|
Posted by Gilles Ganault on 05/08/07 00:17
On 7 May 2007 16:46:27 -0700, klenwell <klenwell@gmail.com> wrote:
>2. smiU - That's modifier overkill. The U here and the ? in your
>expression are probably reacting to each other in unexpected ways.
Ah, ah... Indeed, it seems like it's either using the U switch to make
Preg non-greedy, or use the ? limiter (eg. ".+?"). Thanks for pointing
it out.
Found it: To extract bits, I shouldn't use preg_replace() but
preg_match():
--------------
$url = "http://www.cnn.com";
$response = file_get_contents($url);
preg_match("|<title>(.+?)</title>|smi",$response,$matches);
$response = $matches[1];
$fp = fopen ("output.html", "w");
fputs ($fp,$response);
fclose($fp);
--------------
Thank you.
Navigation:
[Reply to this message]
|