Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.196 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.63; '*S*': 0.02; 'subject:Regular': 0.16; 'subject:expression': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'seems': 0.21; 'email addr:gmail.com>': 0.22; 'form:': 0.24; 'why.': 0.24; 'mon,': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'message-id:@mail.gmail.com': 0.30; 'work:': 0.31; 'regular': 0.32; 'to:name:python-list': 0.33; 'table': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'jason': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'expression': 0.60; 'skip:f 50': 0.65; 'anything.': 0.68; 'skip:r 40': 0.68; 'skip:r 30': 0.69; 'jul': 0.74; 'capture': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ym38NFUvd9mHHpJGM8ZXCkYbLFzq/m7lcJejbhUGdeo=; b=QqP8HEaRtzbXfPeKTaPjhyybKhoODSH46Ctf/eXk5UvScx8o5oJwO8RYsr26VGV2/d xxbdEo2RSaHiGBOuRfdWuod3s0mai0hD288LqWtQZFy1ltfzu9vs+LZDZx9Bj5PhcFSn OlbyuBpMbwTae+FhyH3he9t8lVlZUKQp8ZL7Q1mxSAOFdnskCEabje5JjGIdZ6ZOt8xy mtkCrbnZemiH3LXvx4GqD48+QOACEwRZTZJDf2VPoqOAClsebAwT0WwEx7syvDOlX5NO qUmLcbUJ789WtemaQC4B1H1KH7u1ho8C74Hdzd6np5Ne0GycPhhRrfPdl2b9i40axOcE lYig== MIME-Version: 1.0 X-Received: by 10.50.73.106 with SMTP id k10mr18058940igv.31.1372732071943; Mon, 01 Jul 2013 19:27:51 -0700 (PDT) In-Reply-To: References: Date: Mon, 1 Jul 2013 20:27:51 -0600 Subject: Re: Regular expression negative look-ahead From: Jason Friedman To: python-list Content-Type: multipart/alternative; boundary=089e013a0e028526e504e07e17bf 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: 74 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372733782 news.xs4all.nl 15867 [2001:888:2000:d::a6]:33154 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49604 --089e013a0e028526e504e07e17bf Content-Type: text/plain; charset=UTF-8 Found this: http://stackoverflow.com/questions/13871833/negative-lookahead-assertion-not-working-in-python . This pattern seems to work: pattern = re.compile(r"^(?!.*(CTL|DEL|RUN))") But I am not sure why. On Mon, Jul 1, 2013 at 5:07 PM, Jason Friedman wrote: > I have table names in this form: > MY_TABLE > MY_TABLE_CTL > MY_TABLE_DEL > MY_TABLE_RUN > YOUR_TABLE > YOUR_TABLE_CTL > YOUR_TABLE_DEL > YOUR_TABLE_RUN > > I am trying to create a regular expression that will return true for only > these tables: > MY_TABLE > YOUR_TABLE > > I tried these: > pattern = re.compile(r"_(?!(CTL|DEL|RUN))") > pattern = re.compile(r"\w+(?!(CTL|DEL|RUN))") > pattern = re.compile(r"(?!(CTL|DEL|RUN)$)") > > But, both match. > I do not need to capture anything. > --089e013a0e028526e504e07e17bf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Found this: =C2=A0http://s= tackoverflow.com/questions/13871833/negative-lookahead-assertion-not-workin= g-in-python.

This pattern seems to work:
pattern =3D re.co= mpile(r"^(?!.*(CTL|DEL|RUN))")

But= I am not sure why.


On Mon, Jul 1, 2013 at 5:07 PM, Jason Friedman <jsf80238@gmail.com>= ; wrote:
I have table names in this form:
MY_TABLE
MY= _TABLE_CTL
MY_TABLE_DEL
MY_TABLE_RUN
YOUR_TAB= LE
YOUR_TABLE_CTL
YOUR_TABLE_DEL
YOUR_TABLE_RUN

I am trying to create a regular= expression that will return true for only these tables:
MY_= TABLE
YOUR_TABLE

I tried these= :
pattern =3D re.compile(r"_(?!(CTL|DEL|RUN))")
pattern =3D re.compile(r"\w+(?!(CTL|DEL|RUN))")<= br>
pattern =3D re.compile(r"(?!(CTL|DEL|RU= N)$)")

But, both match.
I do not need to= capture anything.

--089e013a0e028526e504e07e17bf--