Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 90679 invoked from network); 1 Jun 2010 22:40:22 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Jun 2010 22:40:22 -0000 Received: (qmail 24047 invoked by uid 500); 1 Jun 2010 22:40:21 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 24020 invoked by uid 500); 1 Jun 2010 22:40:21 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 24012 invoked by uid 99); 1 Jun 2010 22:40:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Jun 2010 22:40:21 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=AWL,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of Steven.Prentice@nextgen.net designates 203.18.147.131 as permitted sender) Received: from [203.18.147.131] (HELO smtp12.NextGen.Net) (203.18.147.131) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Jun 2010 22:40:16 +0000 Received: from locutus.nextgen.net ([203.18.147.35]) by smtp12.NextGen.Net with ESMTP id 2010060208395390-287423 ; Wed, 2 Jun 2010 08:39:53 +1000 In-Reply-To: <18B33DFB-C665-4F76-85D3-DF9DCA34F52F@googlemail.com> References: <18B33DFB-C665-4F76-85D3-DF9DCA34F52F@googlemail.com> To: user@couchdb.apache.org MIME-Version: 1.0 Subject: Re: Map function with regular expression X-Mailer: Lotus Notes Release 8.0.1 February 07, 2008 Message-ID: From: Steven.Prentice@nextgen.net Date: Wed, 2 Jun 2010 08:39:53 +1000 X-MIMETrack: Serialize by Router on Locutus/NextGen Systems at 02/06/2010 08:39:54 AM, Serialize complete at 02/06/2010 08:39:54 AM, Itemize by SMTP Server on SMTP12/NextGenEXT at 02/06/2010 08:39:53, Serialize by Router on SMTP12/NextGenEXT at 02/06/2010 08:40:15, Serialize complete at 02/06/2010 08:40:15 Content-Type: multipart/alternative; boundary="=_alternative 007C806FCA257735_=" --=_alternative 007C806FCA257735_= Content-Type: text/plain; charset="US-ASCII" I am not getting any results at all, will try your suggestions :) From: Sebastian Cohnen To: user@couchdb.apache.org Date: 01/06/2010 07:06 PM Subject: Re: Map function with regular expression Hey Steven, I have not tested your code, but what seems to be the problem? are you getting errors or simply not the output you anticipated? Some hints though: - you can use log() to emit messages to couchdb's logfile - you should always use guards (like if (doc.Stores) { ... }) otherwise you can easily get nasty bugs - you can use the js console command to test your code On 01.06.2010, at 09:09, Steven.Prentice@nextgen.net wrote: > Hi, > > Ive got a document containing an array and want to perform a regex on an > array item called name, it is located in the Stores field > > what ive got at the moment is... > > function(doc) > { > > for (id in doc.Stores) > { > //regular expression to ensure a store name starts with "C" and ends > with "k" > var strqry = doc.Stores[id].name.match(/^C([a-z]*)k/); > > if (strqry) > { > emit(doc.Stores[id].name, doc.product_name + " qty: " + > doc.Stores[id].item_count); > } > } > } > > a javascript regex validator told me that that regex is correct, I think > it may be something wrong with the way that I am pointing the regex to the > "stores[id].name" > > Cheers :) --=_alternative 007C806FCA257735_=--