Re: [PHP4BETA] perl compatible regex search&replace behaving oddly... bug?
| From: | Andrei Zmievski | Date: | Tue, 18 Jan 2000 14:46:29 +0000 |
| Subject: | Re: [PHP4BETA] perl compatible regex search&replace behaving oddly... bug? | ||
| References: | 1 2 3 4 5 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-9229@lists.php.net to get a copy of this message | ||
On Tue, 18 Jan 2000, Alexander Fordyce wrote:
> I realize that the parse error occurs because it's not finding
> anything nice and executable the second time around. Sometimes it
> produces an ugly binary-looking garbage value for the second variable
> -- it's a bit unpredictable.
No, the parse error occurs because you used $ in a string without
escaping it with \.
> It seems like it should work, as that's the way it's presented in the
> documentation. However, the example from the manual which is
> supposed to upper-case html tags produces similar garbage when I copy
> and paste the code:
>
> - - - - - - - - - - - - - - -
> $html_body = "<P>just some <strong>nice</strong>
> <b>simple</b> text</P>";
> print preg_replace("/(<\/?)(\w+)([^>]*>)/e",
> "'\\1'.strtoupper('\\2').'\\3'", $html_body);
> - - output: - -
> <P>just some rONG>NIcniceb> TEXT</ simple textó(;
> - - - - - - - - - - - - - - -
Hmm, I just ran the exact same code here and it works fine. Perhaps you
could try again?
-Andrei
* It said 'Winmodem' on the box, but I still feel like I lost. *