From dev-return-7391-apmail-couchdb-dev-archive=couchdb.apache.org@couchdb.apache.org Sat Nov 21 07:40:09 2009 Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 3711 invoked from network); 21 Nov 2009 07:40:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Nov 2009 07:40:09 -0000 Received: (qmail 97709 invoked by uid 500); 21 Nov 2009 07:40:08 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 97671 invoked by uid 500); 21 Nov 2009 07:40:07 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 97661 invoked by uid 99); 21 Nov 2009 07:40:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Nov 2009 07:40:07 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Nov 2009 07:40:05 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 1529C234C1F0 for ; Fri, 20 Nov 2009 23:39:41 -0800 (PST) Message-ID: <644070784.1258789181236.JavaMail.jira@brutus> Date: Sat, 21 Nov 2009 07:39:41 +0000 (UTC) From: "Brian Candler (JIRA)" To: dev@couchdb.apache.org Subject: [jira] Commented: (COUCHDB-573) Regex capture problem in emit functions In-Reply-To: <242508195.1258699059656.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/COUCHDB-573?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12780927#action_12780927 ] Brian Candler commented on COUCHDB-573: --------------------------------------- There is no $0 in Javascript, but $& gives the whole substring which matches the regexp. You can try it out using 'js' at the command line (under Ubuntu: install the 'spidermonkey-bin' package) js> 'TestTwo'.replace(/[A-Z]/g, ' $&') Test Two Incidentally, Ruby is the same. $0 is the name of the running script and is nothing to do with regexp captures. ~$ irb --simple-prompt >> $0 => "irb" >> "TestTwo".gsub!(/[A-Z]/) { " #{$&}" } => " Test Two" >> > Regex capture problem in emit functions > --------------------------------------- > > Key: COUCHDB-573 > URL: https://issues.apache.org/jira/browse/COUCHDB-573 > Project: CouchDB > Issue Type: Bug > Affects Versions: 0.11 > Environment: Linux > Reporter: Eric Desgranges > Priority: Trivial > Fix For: 0.11 > > > The capture variables $0, $1, $2... don't get instantiated in regex expressions placed in emit functions. > Example: > function(doc) { if (doc.EntityType != null) { emit(doc.ID.Value + '.' + doc.EntityType, { Type: doc.EntityType.replace(/[A-Z]/g, ' $0'), .... > EntityType: TestTwo > Returns: > Type: " $0est $0wo" > Instead of: > Type: " Test Two" -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.