Reply to Re: [PHP] Regex Help

Your name:

Reply:


Posted by Philip Hallstrom on 09/28/05 20:40

> Hi, folks. I'm having trouble with a simple regex. I'm sure it's just
> something small that I'm missing but nothing I'm trying is working.
>
> In an HTML file I have comments like this:
>
> <!-- START PRINT -->
> various html crap here
> <!-- END PRINT -->
>
> Here's the regex I'm using:
>
> /<!-- START PRINT -->(.*?)<!-- END PRINT -->/
>
> And then the call to preg_match_all():
>
> preg_match_all($printable_reg, $str, $out);
>
> It's been quite a while since I've worked with regular expressions so
> I'm not sure what the problem is. The regex isn't throwing errors, it's
> just not matching the content located between the start print and end
> print comments.
>
> Can anyone lend a hand or give some advice?

I'm thinking that perhaps you want to add the "s" modifier to your
pattern...

From http://us2.php.net/manual/en/reference.pcre.pattern.modifiers.php

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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация