Re: preg_replace brain teaser

From: Date: Wed, 16 Apr 2003 07:39:52 +0000
Subject: Re: preg_replace brain teaser
Groups: php.general 
Request: Send a blank email to php-general+get-144073@lists.php.net to get a copy of this message
Hello Just realized that my intention to do it in just one pattern is pretty stupid and won't work since I'm trying to replace two things at the same time. The actuall match pattern and the escaped { so forget the question. I'll just do it in two replaces. I'll also benchmark the different options (callback, no callback) to see which one is really faster. > You might want to try preg_replace_calback() as it is quite a bit faster. I can't believe that preg_replace_callback is actually faster since it has the overhead of calling a function. I'll post my results. That still leaves the first question to be answered.... any ideas? > "(?<!\\)\{([a-zA-Z0-9_-]+?)\}" which > results in an error: > Warning: Compilation failed: lookbehind assertion is not fixed length at > offset 31 in d:\eclipse_21\workspace\webframework\classes\I18N.class.php > on line 320 > First question (this is slightly off topic) I have is why is the > lookbehind not a fixed length? It should only be one '\'. Stefan Langer

« previous php.general (#144073) next »