Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:module': 0.04; 'subject:using': 0.04; 'character,': 0.07; 'subject:when': 0.07; 'python': 0.08; 'done?': 0.09; 'parsing': 0.09; 'subject:string': 0.09; 'am,': 0.13; 'wrote:': 0.15; '9:20': 0.16; 'subject:define': 0.16; 'cc:addr:python-list': 0.16; 'url:blog': 0.16; 'aug': 0.19; 'cheers,': 0.19; 'work,': 0.20; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'parse': 0.23; 'received:209.85.213.46': 0.23; 'received:mail- yw0-f46.google.com': 0.23; 'tue,': 0.23; 'string': 0.26; 'message- id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.30; 'url:03': 0.30; 'subject:?': 0.31; 'chris': 0.32; 'define': 0.35; 'subject:How': 0.36; 'using': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'url:org': 0.38; 'subject:: ': 0.38; 'should': 0.39; 'received:209': 0.40; 'skip:\xc2 10': 0.74; 'sender:addr:chris': 0.84; 'url:rebertia': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=hWU4xuQgy7KeX2QbI2TdbC8p4VbqS/1JBCpxQF5GfYg=; b=KX/K8BwiCMAmWMtMqr9GEg7Nh3kuMCCrK9XPtVC7zf60tMZivxV7YlTiu/9BTNZMlF IBrZcR4oQ3sCOxDN5dD+YBixCvECnUm2cIWURgRx4j2IRVuqenbPsLOG8aaR8idGKNAB r5g2zsWvNdyMvFu8FW10QtQ5xk6pWv7vOT4C8= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: References: Date: Tue, 2 Aug 2011 10:22:28 -0700 X-Google-Sender-Auth: HKPy8Qdp5sFS2WM71PaO9O8zRtg Subject: Re: How to define repeated string when using the re module? From: Chris Rebert To: smith jack Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1312305752 news.xs4all.nl 23932 [2001:888:2000:d::a6]:46267 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10750 On Tue, Aug 2, 2011 at 9:20 AM, smith jack wrote: > if it's for a single character, this should be very easy, such as > c{m,n} =C2=A0 the occurrence of c is between m and n, > > if i want to define the occurrence of (.*?) =C2=A0how should make i= t > done? =C2=A0((.*?)){1,3} =C2=A0seems not work, any method to define= repeat > string using python regex? Don't parse HTML using regexes; use an HTML parser! http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xht= ml-self-contained-tags Here's a survey of Python HTML parsing libraries: http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ Cheers, Chris -- http://rebertia.com