Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'patterns': 0.04; 'subject:module': 0.04; 'exception,': 0.07; 'pythonistas,': 0.09; "'',": 0.16; 'compile.': 0.16; 'subject: \n ': 0.16; 'cc:addr :python-list': 0.16; '>>>': 0.18; 'repeated': 0.18; 'subject:skip:s 10': 0.18; 'cc:no real name:2**0': 0.21; 'header :In-Reply-To:1': 0.22; 'received:209.85.212.46': 0.23; 'received :mail-vw0-f46.google.com': 0.23; 'here?': 0.23; 'hey': 0.24; 'subject: ?': 0.24; 'cc:2**0': 0.26; 'url:mailman': 0.27; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.29; 'equivalent.': 0.30; 'etc.),': 0.30; 'url:listinfo': 0.32; 'does': 0.32; 'there': 0.33; 'received:209.85.212': 0.33; 'hi,': 0.34; 'however,': 0.35; 'skip:" 20': 0.35; 'url:python': 0.35; 'regular': 0.35; 'but': 0.37; 'received:google.com': 0.37; 'similar': 0.37; 'either': 0.37; 'received:209.85': 0.38; 'some': 0.38; 'think': 0.38; 'fail': 0.39; 'url:org': 0.39; 'received:209': 0.39; 'your': 0.61; 'observed': 0.84; 'optimisation': 0.84; 'subject:Nothing': 0.84; 'subject:nothing': 0.84; 'realistic': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=GjDM4Xmq8JM0VdZlxESMm5im2mScu85s092NNG79xfg=; b=u7BsNj8uMiLFB+hkVQeQbcAxzUk2kWI4/g1pNAngEI25MKJNn4mCY5Hz+jzp8gQgEJ vnbsttMlxr+L3R17qRVp3jEo+2nx84YciuFvfCf8EqBeoWmSwe23b7FGS39r89rt2Klv Q2EQgIqtheWsY4t6jHcn0yRuLryokxcGNTGxg= MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 14 Feb 2012 16:05:51 +0100 Subject: Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? From: Vlastimil Brom To: Devin Jeanpierre Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1329231954 news.xs4all.nl 6896 [2001:888:2000:d::a6]:36075 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20400 2012/2/14 Devin Jeanpierre : > Hey Pythonistas, > > Consider the regular expression "$*". Compilation fails with the > exception, "sre_constants.error: nothing to repeat". > > Consider the regular expression "(?=$)*". As far as I know it is > equivalent. It does not fail to compile. > > Why the inconsistency? What's going on here? > > -- Devin > -- > http://mail.python.org/mailman/listinfo/python-list Hi, I don't know the reason for the observed differences either (I can think of some optimisation issues etc.), but just wanted to mention some other similar patterns to your lookahaed: It seems, that groups (capturing or not capturing) also work ok: >>> re.findall("($)*", "abc") ['', '', '', ''] >>> re.findall("(?:$)*", "abc") ['', '', '', ''] However, is there any realistic usecase for repeated zero-width anchors? regards, vbr