Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31956
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'debugging': 0.05; 'trailing': 0.07; 'any.': 0.09; 'newline,': 0.09; 'match:': 0.16; 'oct': 0.16; 'martin': 0.16; 'wrote:': 0.17; 'statement': 0.23; 'idea': 0.24; 'tried': 0.25; 'header:In-Reply- To:1': 0.25; 'thanks!': 0.26; 'message-id:@mail.gmail.com': 0.27; 'prints': 0.29; 'probably': 0.29; "i'm": 0.29; 'keyword': 0.30; 'received:209.85.215.46': 0.30; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'method': 0.36; 'does': 0.37; 'being': 0.37; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'remove': 0.61; 'everything.': 0.84; 'to:name:python': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=+Pfp05cPpHENHykF6/GnoDIu2HDPeDHP9X6pHrCi4ok=; b=L65svP+q7UFHtZGVNA+t4oAL1ujrQR0BdA4AQ/HCl+uQSpvpOSe8C+GEmefA7jU1Sg FrwznjCzM5YBRK/N+ymWXdzjmw3Q+mPjZbepa9Al39KHJallDkkQPs5yE3oHWRdm2TdD RoL/ewLEMB6KUfCcJU+cskUTtgLjf9D1ymU/7nE5N7NNDz9zgS3qz7tiLg5TM8iBtpYJ GC/6pcgYK6QIUzOEKbtYtQKPRXukPScSSiXcuqaJTMens40uNTVqH2jbSdg2Z/H9ebPV LaU+wZek6ig9wA6kH3yslSISjFIuXQyYtOqPRS9dDZw+r7ksj5GAsrr+NgMosQ5eZYn8 vILQ== |
| MIME-Version | 1.0 |
| In-Reply-To | <0becd1f8-e760-49c1-88d6-1c11b49e203c@googlegroups.com> |
| References | <0becd1f8-e760-49c1-88d6-1c11b49e203c@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Tue, 23 Oct 2012 14:32:31 -0600 |
| Subject | Re: regex function driving me nuts |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2689.1351024383.27098.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1351024383 news.xs4all.nl 6857 [2001:888:2000:d::a6]:33218 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:31956 |
Show key headers only | View raw
On Tue, Oct 23, 2012 at 1:51 PM, MartinD. <cyberdicks@gmail.com> wrote:
> Hi,
>
> I'm new to Python.
> Does someone has an idea what's wrong. I tried everything. The only regex that is tested is the last one in a whole list of regex in keywords.txt
> Thanks!
> Martin
How do you know that it's the only one being tested? Your debugging
statement only prints one that actually matches, not each one that is
tried.
> keywords1 = [line for line in open('keywords1.txt')]
Note that each "keyword" will including the trailing newline, if any.
This is probably why you are only seeing the last keyword match:
because it is the only one without a trailing newline.
To remove the newlines, call the str.strip or str.rstrip method on
each line, or use the str.splitlines method to get the keywords:
keywords1 = open('keywords1.txt').read().splitlines()
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
regex function driving me nuts "MartinD." <cyberdicks@gmail.com> - 2012-10-23 12:51 -0700
RE: regex function driving me nuts "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-23 20:29 +0000
Re: regex function driving me nuts Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-23 14:32 -0600
Re: regex function driving me nuts Vlastimil Brom <vlastimil.brom@gmail.com> - 2012-10-23 22:36 +0200
Re: regex function driving me nuts cyberdicks@gmail.com - 2012-10-23 16:51 -0700
Re: regex function driving me nuts cyberdicks@gmail.com - 2012-10-23 16:51 -0700
Re: regex function driving me nuts Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-10-24 01:27 -0400
csiph-web