Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed6.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'output': 0.04; 'debugging': 0.05; 'completeness': 0.07; 'expressions': 0.07; 'python': 0.09; 'received:155': 0.09; 'str,': 0.09; 'def': 0.10; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'match:': 0.16; 'received:155.180': 0.16; 'received:159.53': 0.16; 'received:169.70': 0.16; 'received:169.70.184': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'securities,': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'martin': 0.16; 'wrote:': 0.17; 'tests': 0.18; 'code.': 0.20; 'to:name:python- list@python.org': 0.20; '2.x': 0.22; 'received:169.254': 0.24; 'idea': 0.24; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'thanks!': 0.26; 'accuracy': 0.27; 'regular': 0.27; 'received:169': 0.29; "i'm": 0.29; 'version,': 0.30; 'error': 0.30; 'figure': 0.30; 'header:Received:8': 0.30; 'helpful': 0.30; 'print': 0.32; 'problem': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'list': 0.35; 'but': 0.36; 'be.': 0.36; 'charset:us- ascii': 0.36; 'operating': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'is.': 0.62; 'provide': 0.62; 'information,': 0.63; 'url:email': 0.63; 'legal': 0.65; 'subject': 0.66; 'purchase': 0.67; 'sale': 0.76; 'everything.': 0.84; 'martin,': 0.84; 'received:169.254.8': 0.84 X-DKIM: OpenDKIM Filter v2.1.3 sf1.jpmchase.com q9NKTOAp022214 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1351024164; bh=Da6/7MKry4ZSP5A/B/XxvmZT7osLO+OeTRu/TMjCXEI=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=DNpuaFghuHZBM3XGvd1JMF62uHvGK3Pfv8OqNKtw1W8it79kWFfAK5mSqNszSMbjl Iy/m/vxHKxMRcvZ0+01tesjpgUU0vaZJtpwF9SfBj7gxK9pEnjwxUYu/B+BvOHzUz5 V7PqIP5lvJXfY5gAEubhkV9zI7sV4anKYF3M8lDg= From: "Prasad, Ramit" To: "python-list@python.org" Subject: RE: regex function driving me nuts Thread-Topic: regex function driving me nuts Thread-Index: AQHNsVhVjjIBAGaET0unwadmKy1G85fHTpnA Date: Tue, 23 Oct 2012 20:29:10 +0000 References: <0becd1f8-e760-49c1-88d6-1c11b49e203c@googlegroups.com> In-Reply-To: <0becd1f8-e760-49c1-88d6-1c11b49e203c@googlegroups.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.79.47] Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-DLP-FWD: Yes Content-Type: text/plain; charset="us-ascii" 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351024173 news.xs4all.nl 6879 [2001:888:2000:d::a6]:59144 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31955 MartinD wrote:=0D=0A> Hi,=0D=0A> =0D=0A> I'm new to Python=2E=0D=0A> Does s= omeone has an idea what's wrong=2E I tried everything=2E The only regex th= at is tested is the last one in a=0D=0A> whole list of regex in keywords=2E= txt=0D=0A> Thanks!=0D=0A> Martin=0D=0A> =0D=0A> =0D=0A> ########=0D=0A> def= checkKeywords( str, lstKeywords ):=0D=0A> =0D=0A> for regex in lstKeyword= s:=0D=0A> match =3D re=2Esearch(regex, str,re=2EIGNORECASE)=0D=0A> # If= -statement after search() tests if it succeeded=0D=0A> if match:=0D=0A> = print match=2Egroup() ##just debugging=0D=0A> return match=2Egroup() #= # 'found!=0D=0A> =0D=0A> return=0D=0A> =0D=0A> #########=0D=0A> =0D=0A> ke= ywords1 =3D [line for line in open('keywords1=2Etxt')]=0D=0A> resultKeyword= s1 =3D checkKeywords("string_to_test",keywords1)=0D=0A> print resultKeyword= s1=0D=0A> =0D=0A=0D=0AHi Martin,=0D=0AIt is always helpful to provide pytho= n version, operating system version, full error message,=0D=0Aand input/exp= ected output for the code=2E Now I can tell you are using Python 2=2Ex but = =0D=0Awithout having any clue what is in keywords1=2Etxt it is impossible t= o figure out=0D=0Awhat the problem might be=2E Other than using regular exp= ressions that is=2E :)=0D=0A=0D=0ARamit Prasad=0D=0A=0D=0A=0D=0AThis email = is confidential and subject to important disclaimers and=0D=0Aconditions in= cluding on offers for the purchase or sale of=0D=0Asecurities, accuracy and= completeness of information, viruses,=0D=0Aconfidentiality, legal privileg= e, and legal entity disclaimers,=0D=0Aavailable at http://www=2Ejpmorgan=2E= com/pages/disclosures/email=2E