Re: Re: Bug #1683 Updated: Failing to parse/compile a *? pattern.
| From: | Jonathan Roy | Date: | Fri, 09 Jul 1999 14:02:23 +0000 |
| Subject: | Re: Re: Bug #1683 Updated: Failing to parse/compile a *? pattern. | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-8247@lists.php.net to get a copy of this message | ||
Howdy. Sure. A tiny bit of background. Phorum has this regexp:
$body=eregi_replace("<([^:]*://[^ >\n\t]*)>", "<a
href=\"\\1\">\\1</a>", $body);
where the 2nd * being greedy means two links on the same line are treated
like a single long link. I want the second * to be non-greedy. So in theory
I just do this:
$body=preg_replace("/<([^:]*:\/\/[^ >\n\t]*?)>/i", "<a
href=\"\\1\">\\1</a>", $body);
however, that tells me "illegal escape sequence \/". Trying to debug my
regexp, I tried this line:
$body=preg_replace("/\//", "", $body);
same error. However, the stand-alone program:
<?PHP
$body=preg_replace("/\//", "", $body);
?>
creates no error message. If you want to reproduce this, and happen to
have phorum yourself, put my small preg_replace command in around line 183
or so of post.php3, after the closing } and before the two egrei_replace
commands. This is with Apache 1.3.6, php 3.0.11, on a linux redhat 5
machine.
At least, it'll reproduce it on my machine/setup.
-Jonathan
*********** REPLY SEPARATOR ***********
On 7/9/99 at 8:53 AM Andrey Zmievski wrote:
>Jonathan Roy wrote:
>> But no matter. preg with non-greedy matching will do it, if I can ever
>> make preg work. In my stand alone test program, the preg regexp "/\//"
is
>> fine and works. In the actual program I'm trying to replace an egreg
with
>> it, it tells me "illegal escape sequence \/". I'm about to give up and
let
>> someone else fix this Phorum bug. :)
>
>Can you give me the exact regexp you're having problems with?
>
>-Andrey
>* The future has arrived, it's just not evenly distributed. -W. Gibson *
---
Jonathan Roy - roy@idle.com - Idle Communications, Inc.