couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Cottlehuber <d...@muse.net.nz>
Subject Re: Map function with regular expression
Date Tue, 01 Jun 2010 09:12:04 GMT
>>    //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/);

I'm a perl guy so assuming
http://www.regular-expressions.info/anchors.html this is accurate
then:

the regex above (assuming perl & javascript regex are similar) is actually:

match on starting with capital C, followed only by 0 or more lower
case letters, then k. Your pattern is not terminated at the end of the
string, so CookIslands would match. Not sure if that's what you want
or not. This might be more your needs  - match capital C followed by 0
or more characters and lower k followed by end of string.

/^C.*k$/

A+
Dave

Mime
View raw message