PHP regular expressions

He has: 14 posts

Joined: Sep 2005

Hi there,

Given $data is an html file read as a string and the code:

<?php
$regex
= \"/&lt;script(.|[\n\r])*?.*&gt;(.|[\n\r])*?<\/script>/s\";
$data = preg_replace($regex,\"\",$data);
?>

Why can't I get rid of the $regex (everything in between opening and closing <script> tags) for http://www.bestbuy.ca/catalog/proddetail.asp?langid=EN&sku_id=0926INGFS10071957

... but the following would do the preg_replace properly:
http://cgi.ebay.ca/Canon-PowerShot-Pro90-IS-2-6-Megapixel-Pristine-Cond_W0QQitemZ220001534621QQihZ012QQcategoryZ43454QQrdZ1QQcmdZViewItem

I initially thought my regex was incorrect, but then it gets rid of all the script tags and everything in between in the Ebay page, while it fails on the BestBuy page.

Any ideas why?