Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51685 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65679 invoked from network); 14 Mar 2011 18:38:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Mar 2011 18:38:58 -0000 Authentication-Results: pb1.pair.com header.from=mail_ben_schmidt@yahoo.com.au; sender-id=unknown; domainkeys=good Authentication-Results: pb1.pair.com smtp.mail=mail_ben_schmidt@yahoo.com.au; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain yahoo.com.au from 98.139.91.81 cause and error) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: mail_ben_schmidt@yahoo.com.au X-Host-Fingerprint: 98.139.91.81 nm11.bullet.mail.sp2.yahoo.com Received: from [98.139.91.81] ([98.139.91.81:42193] helo=nm11.bullet.mail.sp2.yahoo.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 42/C8-16045-0C06E7D4 for ; Mon, 14 Mar 2011 13:38:57 -0500 Received: from [98.139.91.69] by nm11.bullet.mail.sp2.yahoo.com with NNFMP; 14 Mar 2011 18:38:54 -0000 Received: from [98.139.91.39] by tm9.bullet.mail.sp2.yahoo.com with NNFMP; 14 Mar 2011 18:38:54 -0000 Received: from [127.0.0.1] by omp1039.mail.sp2.yahoo.com with NNFMP; 14 Mar 2011 18:38:54 -0000 X-Yahoo-Newman-Id: 408788.80881.bm@omp1039.mail.sp2.yahoo.com Received: (qmail 71575 invoked from network); 14 Mar 2011 18:38:53 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.au; h=DKIM-Signature:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=DHu8/l8/e/kdwTf6GFlHxv8bgX6/cI+38PuTVYESQYm0XQZm0ihjPoWathjCulGdZfA/abWtjpyBgbrt657bP0xOBjeTWmVfvosR1W83aC9GHkYLtZj8OW+wbnY/LoEH1QaRiGdh6sd6sQHazYXlOCDxXg68KerfPyI3vgUUzjI= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com.au; s=s1024; t=1300127933; bh=Y5Dq0t/QyALe0ITmQy24of5xuzn274gINn4yaI7Mq0A=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=fJ4Bg3b5mkuAvPhcL9ArXASzlV2nbP0y0k445AwFjt0Ksn3EtdOZBFtf6nsItv5C1g3TQViPZcul3TKsH7+e0Mc0szzGKt1LtkVJQvMmPGWjfkrel5kyYOAmtUZ2DwH7qDZVRtJ8GPkO/+Wd08oR6R6stnht5B7Z5Hnw/9E8nTk= Received: from thought.local (mail_ben_schmidt@203.217.72.107 with plain) by smtp139.mail.mud.yahoo.com with SMTP; 14 Mar 2011 11:38:53 -0700 PDT X-Yahoo-SMTP: enFMnPSswBAexaHyzgobwuUTrYOhZdJ0KRA2SjA- X-YMail-OSG: VgEJtsMVM1m1JG_fGc8haBuB_UJMm1kJtBiyTvw1VSQ38Dq 7RElWQSxyRxXYl7RlmaHKNeyYqZpa6g2fT6KWaFOCyjctTTd9K2iM2bA1rXY 1UI7jKy5ScI13PLGL0PbL0XsbyuBuSOD_XqZzeC.nS7XHkew798e3.cXvY05 w7uHVfe.qOhi78jVTpOL2sfW2LL8KeNJ2TvOMfj7zbgas6OGrHtXmMLMRP7K 942.nfQqDwE_OgGB4AH3DzNkgfRuCR1mVAG0.svUl9vVoqLLY4k0GKipp3A7 Rr7oXjGmJfb14CWbnc07R8is3Q6Lt_miWe2Zmqbw9B8qAhSEe2oi9sQz0dTk UxcVS.rD7j_3U_FjZU09GsnuNd3g- X-Yahoo-Newman-Property: ymail-3 Message-ID: <4D7E60BA.4040208@yahoo.com.au> Date: Tue, 15 Mar 2011 05:38:50 +1100 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-GB; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 ThunderBrowse/3.3.5 MIME-Version: 1.0 To: Martin Scotta CC: PHP internals References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] preg_replace does not replace all occurrences From: mail_ben_schmidt@yahoo.com.au (Ben Schmidt) On 15/03/11 2:18 AM, Martin Scotta wrote: > I chose the simplest example to show the preg_replace behavior, You've GOT to be kidding. The SIMPLEST?! How about an example that doesn't require escaping ALL the interesting characters involved? Here's a modified version that I think it quite a bit simpler: The way I interpret it, it should put an 'a' before every 'b' that is not already preceded by an 'a'. But the buggy case gives 'str abb str' rather than the expected 'str abab str'. It does look like a bug to me. Ben. > there are > better (and safer) ways to scape slash characters. > Anyways, *is this the expected preg_replace behavior?* > > Martin > > function test($str) { > static $re = '/(^|[^\\\\])\'/'; > static $change = '$1\\\''; > > echo $str, PHP_EOL, > preg_replace($re, $change, $str), PHP_EOL, PHP_EOL; > } > > test("str '' str"); // bug? > test("str \\'\\' str"); // ok > test("'str'"); // ok > test("\'str\'"); // ok > > ---- > Expected: > > str '' str > str \'\' str > > str \'\' str > str \'\' str > > 'str' > \'str\' > > \'str\' > \'str\' > > ---- > Result: > > str '' str > str \'' str > > str \'\' str > str \'\' str > > 'str' > \'str\' > > \'str\' > \'str\' > > > Martin Scotta >