Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'expressions': 0.07; 'matches': 0.07; 'string': 0.09; 'counting': 0.09; 'prefix': 0.09; 'prefixes': 0.09; 'subject:string': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'question.': 0.14; 'subject: \n ': 0.16; 'subject:possible': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'library': 0.18; 'machine': 0.22; 'input': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'characters': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'that.': 0.31; 'subject:other': 0.31; 'subject:that': 0.31; 'probably': 0.32; 'regular': 0.32; 'run': 0.32; 'another': 0.32; 'running': 0.33; "i'd": 0.34; 'but': 0.35; 'received:google.com': 0.35; '(we': 0.36; 'possible': 0.36; 'should': 0.36; 'does': 0.39; 'how': 0.40; 'to:addr:gmail.com': 0.65; 'subject:check': 0.84; 'upside': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=aLUDRvjzl+wjS1QVBSpZrmpLpWhvsWKI/5hP+v9R/5k=; b=xSk0D9gcf796HOeNnZb2JUDwbEVp/Yqe6u48grugKXdb4lTwNXTkFUls4meYI/z4Yl AS/D6jBG/97dPg+4sUJFHI6iFztC8u8wppPjo/OH+Aw2uq8KT7d9AT+7A255vUp6dWUs UMGjxa8m3Zc4gDewCp2zwWgHjzVEna5/SlnkB0eaHDJdDxLqPY5cG0nVM3qFoHKAjpZG PV3oG77cv1IQnFpSM6pzktz4PYjGEO2o9XWVQo/1778r64lCyqiIgbPaYIXEN7KcEw4v G8o+QHyqBh9PqXf5WeHZYziZ0O0IS67mdfrms7HdEqiQVlgd4xGrHL6NkF6JI9IVt24w Avpw== X-Received: by 10.112.129.228 with SMTP id nz4mr5330551lbb.9.1412701356797; Tue, 07 Oct 2014 10:02:36 -0700 (PDT) MIME-Version: 1.0 Sender: joshua.landau.ws@gmail.com In-Reply-To: References: From: Joshua Landau Date: Tue, 7 Oct 2014 18:01:56 +0100 X-Google-Sender-Auth: jbXl2Iwv5FCd3UcDZnIDNCeKqTM Subject: Re: How do I check if a string is a prefix of any possible other string that matches a given regex. To: jonathan.slenders@gmail.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412701359 news.xs4all.nl 2875 [2001:888:2000:d::a6]:53713 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78806 On 7 October 2014 17:15, wrote: > Probably I'm turning the use of regular expressions upside down with this= question. I don't want to write a regex that matches prefixes of other str= ings, I know how to do that. I want to generate a regex -- given another re= gex --, that matches all possible strings that are a prefix of a string tha= t matches the given regex. > [...] > Logically, I'd think it should be possible by running the input string ag= ainst the state machine that the given regex describes, and if at some poin= t all the input characters are consumed, it's a match. (We don't have to ru= n the regex until the end.) But I cannot find any library that does it... How wide a net are you counting "regular expressions" to be? What grammar are you using?