Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49604 > unrolled thread

Re: Regular expression negative look-ahead

Started byJason Friedman <jsf80238@gmail.com>
First post2013-07-01 20:27 -0600
Last post2013-07-01 20:27 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Regular expression negative look-ahead Jason Friedman <jsf80238@gmail.com> - 2013-07-01 20:27 -0600

#49604 — Re: Regular expression negative look-ahead

FromJason Friedman <jsf80238@gmail.com>
Date2013-07-01 20:27 -0600
SubjectRe: Regular expression negative look-ahead
Message-ID<mailman.4087.1372733782.3114.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

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 <jsf80238@gmail.com> 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.
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web