Re: Bug in preg_match() ?
| From: | Nuno Lopes | Date: | Sun, 11 Jul 2004 19:07:42 +0000 |
| Subject: | Re: Bug in preg_match() ? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-11097@lists.php.net to get a copy of this message | ||
> Hi,
>
> This script:
>
> <?
> $line = "Use operator m// for matching strings";
> $pattern = "m//";
>
> if(preg_match("/$pattern/", $line, $match)) {
> print $match[0]."\n";
> }
> ?>
There is no bug here!
The final pattern is "/m///". When using // as delimeters, you must escape
them, so you would need to set
$pattern="m\/\/"
*or*
using other delimeter such as '~':
preg_match("~$pattern~",...)
Nuno