RE: [PHP] perl regex help
| From: | John W. Holmes | Date: | Sun, 02 Feb 2003 15:08:07 +0000 |
| Subject: | RE: [PHP] perl regex help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-133999@lists.php.net to get a copy of this message | ||
> if
> . matches any character except newline (by default)
> then
> what can i use to match any character INCLUDING newline?
Use an 's' modifier.
Quote: 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.
Example: preg_match("!<tag>(.*)</tag>!s",$string,$matches);
http://www.php.net/manual/en/pcre.pattern.modifiers.php
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/