Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'debugging': 0.05; 'newline': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'str,': 0.09; 'def': 0.10; 'marker': 0.16; 'match:': 0.16; 'oct': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'martin': 0.16; 'tests': 0.18; 'idea': 0.24; 'tried': 0.25; 'thanks!': 0.26; 'header:X -Complaints-To:1': 0.28; "i'm": 0.29; 'print': 0.32; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'list': 0.35; 'received:org': 0.36; 'charset:us-ascii': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'your': 0.60; 'everything.': 0.84; 'dennis': 0.91; 'received:108': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: regex function driving me nuts Date: Wed, 24 Oct 2012 01:27:04 -0400 Organization: > Bestiaria Support Staff < References: <0becd1f8-e760-49c1-88d6-1c11b49e203c@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-79-220-228.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351056598 news.xs4all.nl 6943 [2001:888:2000:d::a6]:54246 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31994 On Tue, 23 Oct 2012 12:51:34 -0700 (PDT), "MartinD." declaimed the following in gmane.comp.python.general: > 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 > > > ######## > def checkKeywords( str, lstKeywords ): > > for regex in lstKeywords: > match = re.search(regex, str,re.IGNORECASE) > # If-statement after search() tests if it succeeded > if match: > print match.group() ##just debugging > return match.group() ## 'found! > > return > > ######### > > keywords1 = [line for line in open('keywords1.txt')] Off-hand, your list of "keywords1" still has a newline marker at the end of each entry... -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/