Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.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; 'else:': 0.03; 'subject:Python': 0.06; 'error:': 0.07; 'failing': 0.07; 'string': 0.09; 'escape': 0.09; 'formatting': 0.09; 'mixed': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'bracket': 0.16; 'helps.': 0.16; 'received:143': 0.16; 'subject:simple': 0.16; 'folks': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'question': 0.24; 'cc:2**0': 0.24; 'source': 0.25; 'header :In-Reply-To:1': 0.27; 'dec': 0.30; 'skip:( 20': 0.30; 'code': 0.31; 'breaking': 0.31; 'prints': 0.31; 'testing.': 0.31; 'trivial': 0.31; 'text': 0.33; 'sense': 0.34; 'received:209.85': 0.35; 'anywhere': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'should': 0.36; 'received:209': 0.37; 'bad': 0.39; 'sure': 0.39; 'skip:u 10': 0.60; 'hope': 0.61; 'here:': 0.62; 'content-disposition:inline': 0.62; 'skip:n 10': 0.64; 'to:addr:gmail.com': 0.65; 'url:me': 0.69 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=1le7hyT6g3oQOGPdE9lzF0Fm009ke8iQT7wHGOP7oJ8=; b=cAT+W97lCuCTNyhExz/ZgC6HTkq84ZGMlQmbzIV7oKUSLx7OkrZXg/yUGZ4XQr0u0Z vKCFHi0bu1UzdEhQVNThd7BT9wWAHMWjbF4IoTfms3Xm/muCf9HQn1f9/0Q1xWN6C7nt wWhdiGwccmyavSwzjC3sfnFkZwUBnhZ5S6Z0g4JrtglmriLJzQcMNC6UVD3osNhl3S11 u7kl7uRdWKPurOF8eDmGndOxfifI/TrA8bE8OjQ+pAjyvbi8xHJ3KAoWJAdEoZVTeXE5 rHwY2rjikfobLi29K25fZDXTxQPfqtKm33cJnbQEP9qtn3tjQtOIpHFpMBLegUukoXxS HOOA== X-Gm-Message-State: ALoCoQlH6s0KESAcmSn5phg7qWHMbxZP1acEngAp11AkBm8kMHs0MTEkCzc0L06FjIi2oHeOUk1D X-Received: by 10.70.92.138 with SMTP id cm10mr17931236pdb.133.1418022633893; Sun, 07 Dec 2014 23:10:33 -0800 (PST) Date: Mon, 8 Dec 2014 15:10:29 +0800 From: Shiyao Ma To: Ganesh Pal Subject: Re: Python re.search simple question References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: All mail clients suck. This one just sucks way more. X-Info: Find me @introom on Freenode. Have beers! :) Cc: "python-list@python.org" 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418022637 news.xs4all.nl 2906 [2001:888:2000:d::a6]:47837 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82111 On Dec 08 at 12:22 +0530, Ganesh Pal wrote: > Hi Folks , > > This might seem to be very trivial question but iam breaking my head over > it for a while . > > My understanding is that re.search should search for the match anywhere in > the string . > > > why is re.search failing in the below case ?? > > >>> pattern > 'Token-based migrations cannot be mixed with level-based: [prev 0 , now 1]' I sense a bad smell. Be sure to escape the bracket [ ] > >>> text > ' LogMessage {type NDMP_LOG_DBG} {msg_id 0} {msg The process id for NDMP > service is 0x9c216370} {associated_msg 0} {associated_msg_seq 0} Source > filer:DartOS Error: Token-based migrations cannot be mixed with > level-based: [prev 0 , now 1]' > > >>> if (re.search(pattern,text)): > ... print "Hi" > ... else: > ... print "BYE" > ... so see here: https://bpaste.net/show/d2f1cf66a492 . It prints "HI" /me always wishes code is sent without others doing some extra formatting before testing. Hope that helps. -- Shiyao Ma http://introo.me