Вот кусок текста:<p style="text-align: center"> <noindex><!-- google_ad_client = "pub-4283828625305118"; /* 468x60, создано 28.08.09 */ google_ad_slot = "8947185438"; google_ad_width = 468; google_ad_height = 60; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></noindex><br /><br /> Я хочу от тега <noindex>до тега</noindex> все нафиг стереть. Правильно ли будет написать так preg_replace(!<noindex>(.*?)</noindex>!i,'',$txt); У меня не проходит наверное из-за того что .-соответствует любому символу, за исключением символа новой строки Как же тогда быть???
Pattern Modifiers: s (PCRE_DOTALL) If this modifier is set, a dot metacharacter in the pattern matches all characters, including newlines. Without it, newlines are excluded. This modifier is equivalent to Perl's /s modifier. A negative class such as [^a] always matches a newline character, independent of the setting of this modifier.
PHP: <?php ini_set('display_errors',1); error_reporting(E_ALL); setlocale(LC_ALL, 'ru_RU.CP1251', 'rus_RUS.CP1251', 'Russian_Russia.1251'); $m='<p style="text-align: center"> <noindex><!-- google_ad_client = "pub-4283828625305118"; /* 468x60, создано 28.08.09 */ google_ad_slot = "8947185438"; google_ad_width = 468; google_ad_height = 60; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></noindex><br /><br />'; $poisk='/<noindex>(.+)<\/noindex>/si'; preg_match($poisk,$m,$matches); echo $matches[1]; ?>