Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'found,': 0.07; 'subject:bug': 0.07; 'suppose': 0.07; 'occurrences': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'jan': 0.12; 'translation': 0.12; '2.7': 0.14; "'+'": 0.16; "'}'": 0.16; 'fine.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:expression': 0.16; 'subject:possible': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'raise': 0.29; 'wonder': 0.29; "doesn't": 0.30; 'matching': 0.30; 'code': 0.31; "skip:' 10": 0.31; 'argue': 0.31; 'disable': 0.31; 'alone': 0.33; 'could': 0.34; 'but': 0.35; 'there': 0.35; 'whilst': 0.36; 'subject:?': 0.36; 'should': 0.36; 'error.': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:a 30': 0.61; 'received:173': 0.61; 'more': 0.64; 'special': 0.74; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: possible bug in re expression? Date: Fri, 25 Apr 2014 14:32:30 -0400 References: <535A8DB5.4090109@chamonix.reportlab.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-254-207.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 In-Reply-To: <535A8DB5.4090109@chamonix.reportlab.co.uk> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1398450797 news.xs4all.nl 2848 [2001:888:2000:d::a6]:58097 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70611 On 4/25/2014 12:30 PM, Robin Becker wrote: > Whilst translating some javascript code I find that this > > A=re.compile('.{1,+3}').findall(p) > > doesn't give any error, but doesn't manage to find the strings in p that > I want len(A)==>0, the correct translation should have been > > A=re.compile('.{1,3}').findall(p) > > which works fine. > > should > > re.compile('.{1,+3}') > > raise an error? It doesn't on python 2.7 or 3.3. And it should not because it is not an error. '+' means 'match 1 or more occurrences of the preceding re' and the preceding re is ','. >>> re.match('a{1,+3}', 'a{1,,,3}').group() 'a{1,,,3}' I suppose that one could argue that '{' alone should be treated as special immediately, and not just when a matching '}' is found, and should disable other special meanings. I wonder what JS does if there is no matching '}'? -- Terry Jan Reedy